如何在Ubuntu18.04系統(tǒng)安裝mysql
如何在Ubuntu18.04系統(tǒng)安裝mysql
MySQL是一個(gè)開源的小型關(guān)聯(lián)式資料庫管理系統(tǒng).在Ubuntu18.04系統(tǒng)中,如何安裝mysql?本文將針對此問題進(jìn)行說明。
1.首先更新軟件列表
sudo apt-get update
2.然后安裝mysql-server
sudo apt-get install mysql-server
3.運(yùn)行完之后輸入以下指令,可以查看mysql是否運(yùn)行
service mysql status
反饋
Mysql正常運(yùn)行
4.登錄mysql
mysql -u root -p
密碼為空,進(jìn)入mysql
5.設(shè)置root賬號的密碼
依次運(yùn)行以下命令
use mysql;
update mysql.user set authentication_string=password('你的密碼') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
設(shè)置完成
6.查看debian-sys-maint用戶密碼
Ubuntu在安裝MySQL時(shí)會(huì)為用戶創(chuàng)建一個(gè)debian-sys-maint用戶。如果忘記密碼的話可以通過登錄debian-sys-maint用戶進(jìn)行修改。
sudo cat /etc/mysql/debian.cnf
7.之后用該用戶密碼登錄后就可以修改root密碼了
mysql -u debian-sys-maint -p