Ubuntu 安装配置MySQL5.7

环境

Ubuntu18.07
参考文章

安装

  1. 更新软件
sudo apt-get update
  1. 安装MySQL服务器
sudo apt install mysql-server-5.7

  1. 检查MySQL
sudo apt install net-tools
sudo netstat -tap | grep mysql

mysql -V

  1. 查看默认账户和密码
sudo cat /etc/mysql/debian.cnf

配置

查看状态

systemctl status mysql.service

修改密码

sudo mysql -uroot -p
  1. 查看用户
select user, plugin from mysql.user;

update mysql.user set authentication_string=PASSWORD('123456'), plugin='mysql_native_password' where user='root';
flush privileges;

添加用户,创建数据库

  1. 授权root用户远程访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql > flush PRIVILEGES;
  1. 创建test用户并授权本地访问
mysql > GRANT ALL PRIVILEGES ON *.* TO 'test'@localhost IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql > flush PRIVILEGES;

posted @ 2022-11-21 19:41  伶俐虫虫  阅读(761)  评论(3编辑  收藏  举报