Ubuntu 安装配置MySQL5.7
环境
Ubuntu18.07
参考文章
安装
- 更新软件
sudo apt-get update
- 安装MySQL服务器
sudo apt install mysql-server-5.7
- 检查MySQL
sudo apt install net-tools
sudo netstat -tap | grep mysql
mysql -V
- 查看默认账户和密码
sudo cat /etc/mysql/debian.cnf
配置
查看状态
systemctl status mysql.service
修改密码
sudo mysql -uroot -p
- 查看用户
select user, plugin from mysql.user;
update mysql.user set authentication_string=PASSWORD('123456'), plugin='mysql_native_password' where user='root';
flush privileges;
添加用户,创建数据库
- 授权root用户远程访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql > flush PRIVILEGES;
- 创建test用户并授权本地访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'test'@localhost IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql > flush PRIVILEGES;