在Ubuntu20.04上安装MySQL8.0及正确配置[已验证]


sudo apt-get update  #更新源
sudo apt-get install mysql-server #安装

create user 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%';
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
flush privileges;


create database swtest;
create user 'swadmin'@'%' identified by 'p@ssw0rd@sw';
grant all privileges on *.* to 'swadmin'@'%' with grant option;
flush privileges;


alter user 'root'@'%' identified with mysql_native_password by '123456';

 

安装说明:

mysqld install MySQL3303  --defaults-file="C:\Program Files\MySQL\8.0.18\MySQL3303.ini"
mysqld install MySQL3306  --defaults-file="C:\Program Files\MySQL\8.0.18\MySQL3306.ini"

mysqld --defaults-file="C:\Program Files\MySQL\8.0.18\MySQL3303.ini" --initialize --console
mysqld --defaults-file="C:\Program Files\MySQL\8.0.18\MySQL3306.ini" --initialize --console 

net start MySQL3303
net start MySQL3306

mysql -P3303 -uroot -p
输入原始密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
use mysql;
select host, user, plugin from user;

mysql -P3306 -uroot -p
输入原始密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
use mysql;
select host, user, plugin from user;



卸载说明:
mysqld -nt -remove "MySQL3303"
net stop "MySQL3303"
sc delete MySQL3303

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM