在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