ningleesherry 发表于 2018-10-6 06:40:51

源码编译安装 MySQL 5.5.x-Csslinux

创建my.cnf配置文件  #mkdir /opt/mysql/log
  #mkdir /opt/mysql/etc
  #cp support-files/my-medium.cnf /opt/mysql/etc/my.cnf
  初始化数据库
  执行前需赋给scripts/mysql_install_db文件执行权限
  #chmod 755 scripts/mysql_install_db
  #scripts/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/opt/mysql/data/
  创建管理MySQL数据库的shell脚本
  #mkdir /opt/mysql/init.d
  #cp support-files/mysql.server /opt/mysql/init.d/mysql
  赋予shell脚本可执行权限:
  #chmod +x /opt/mysql/init.d/mysql
  启动MySQL:
  #/opt/mysql/init.d/mysql start
  通过命令行登录管理MySQL服务器(提示输入密码时直接回车):
  #/opt/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
  输入以下SQL语句,创建一个具有root权限的用户(admin)和密码(12345678):

  GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost'>
  GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1'>  为root帐户设置初始密码
  #/opt/mysql/bin/mysqladmin -u root password 'new-password'
  删除本机匿名连接的空密码帐号
  /opt/mysql/bin/mysql -uroot -p'new-password'
  mysql>use mysql; //选择系统数据库mysql
  mysql>select Host,User,Password from user; //查看所有用户
  mysql>delete from user where password="";
  mysql>flush privileges;
  mysql>select Host,User,Password from user; //确认密码为空的用户是否已全部删除
  mysql>exit;

页: [1]
查看完整版本: 源码编译安装 MySQL 5.5.x-Csslinux