当前位置:Gxlcms > 数据库问题 > linux上安装mysql5.7

linux上安装mysql5.7

时间:2021-07-01 10:21:17 帮助过:30人阅读

  1. [mysqld]
  2. datadir=/usr/local/mysql/data
  3. basedir=/usr/local/mysql
  4. socket=/tmp/mysql.sock
  5. user=mysql
  6. port=3306
  7. character-set-server=utf8<br># 取消密码验证<br>skip-grant-tables
  8. # Disabling symbolic-links is recommended to prevent assorted security risks
  9. symbolic-links=0
  10. # skip-grant-tables
  11. [mysqld_safe]
  12. log-error=/var/log/mysqld.log
  13. pid-file=/var/run/mysqld/mysqld.pid
技术图片

7、开启服务

# 将mysql加入服务

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

# 开机自启

chkconfig mysql on

# 开启

service mysql start

8、设置密码

# 登录(由于/etc/my.cnf中设置了取消密码验证,所以此处密码任意)

/usr/local/mysql/bin/mysql -u root -p

# 操作mysql数据库

>>use mysql;

# 修改密码

>>update user set authentication_string=password(‘你的密码‘) where user=‘root‘;

>>flush privileges;

>>exit;

9、将/etc/my.cnf中的skip-grant-tables删除

10、登录再次设置密码(不知道为啥如果不再次设置密码就操作不了数据库了)

/usr/local/mysql/bin/mysql -u root -p

 >>ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘修改后的密码‘;

>>exit;

11、允许远程连接

/usr/local/mysql/bin/mysql -u root -p

>>use mysql;

>>update user set host=‘%‘ where user = ‘root‘;

>>flush privileges;

>>eixt;

12、添加快捷方式

ln -s /usr/local/mysql/bin/mysql /usr/bin

linux上安装mysql5.7

标签:lin   mysql数据库   initial   sed   prevent   开机   serve   编辑   命令   

人气教程排行