日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

阿里云ubuntu mysql_Ubuntu下安装MySQL(阿里云服务器)

發(fā)布時間:2025/3/15 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 阿里云ubuntu mysql_Ubuntu下安装MySQL(阿里云服务器) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

安裝客戶端和依賴環(huán)境

sudo apt install mysql-server #安裝mysql服務器端

sudo apt install mysql-client #安裝mysql客戶端

sudo apt install libmysqlclient-dev #安裝服務端/客戶端依賴環(huán)境(可有可無,建議安裝)

初始化MySQL(MySQL 5.7并未設置默認密碼,需要初始化,即運行安全向?qū)?

sudo mysql_secure_installation

安全向?qū)?#xff1a;

1.(是否設置隨機密碼,Y/y隨機密碼, N/n自己輸入密碼)

VALIDATE PASSWORD PLUGIN can be used to test passwords...

Press y|Y for Yes, any other key for No: N (我的選項)

Please set the password for root here...

New password: (輸入密碼)

Re-enter new password: (重復輸入)

2.(是否刪除匿名用戶,建議刪除)

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them...

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y (我的選項)

3.(是否禁止root賬戶遠程登陸,建議禁止)

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network...

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的選項)

4.(是否刪除test數(shù)據(jù)庫,建議刪除)

By default, MySQL comes with a database named 'test' that

anyone can access...

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y (我的選項)

5.(是否重新加載權(quán)限表,應該重新加載)

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的選項)

修改配置文件(具體的看是否需要遠程訪問數(shù)據(jù)庫)

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

/bind #查找bind-address,然后注釋該行并保存

重啟MySQL服務

sudo service mysql restart

從MySQL-Client登陸MySQL(首次登陸建議以root用戶身份登陸)

mysql -u root -p

創(chuàng)建用來遠程登陸的用戶

create user 用戶名(非root用戶)

為新建立的用戶賦予相應權(quán)限

grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;

# grant 修改用戶權(quán)限的關(guān)鍵字

# all(增、刪、改、查、創(chuàng)建數(shù)據(jù)庫和表等,除grant外的所有權(quán)限)

# on 后面跟數(shù)據(jù)庫名.表名(*代表所有)

# to 'username'@'ip'(%代表所有IP均可訪問該數(shù)據(jù)庫)

# identified by 'password'

# 關(guān)鍵字:privileges、with grant option

必須使用flush privileges的兩種情況

1、改密碼。

2、授權(quán)超用戶。

flush privileges 命令本質(zhì)上的作用是將當前user和privilige表中的用戶信息/權(quán)限設置從mysql庫(MySQL數(shù)據(jù)庫的內(nèi)置庫)中提取到內(nèi)存里

總結(jié)

以上是生活随笔為你收集整理的阿里云ubuntu mysql_Ubuntu下安装MySQL(阿里云服务器)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。