日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

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

安裝客戶端和依賴環境

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

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

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

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

sudo mysql_secure_installation

安全向導:

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數據庫,建議刪除)

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.(是否重新加載權限表,應該重新加載)

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 (我的選項)

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

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

創建用來遠程登陸的用戶

create user 用戶名(非root用戶)

為新建立的用戶賦予相應權限

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

# grant 修改用戶權限的關鍵字

# all(增、刪、改、查、創建數據庫和表等,除grant外的所有權限)

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

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

# identified by 'password'

# 關鍵字:privileges、with grant option

必須使用flush privileges的兩種情況

1、改密碼。

2、授權超用戶。

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

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。