1. 程式人生 > 其它 >ubuntu18.04下mysql-server的安裝(圖解詳細)

ubuntu18.04下mysql-server的安裝(圖解詳細)

1.更換軟體源的地址

使用原來國外的源地址下載軟體很慢,更換成國內的源地址

在 /etc/apt目錄下有一個sources.list軟體源目錄

 把原來檔案修改名字,做個備份:

把原來檔案修改名字,做個備份: 
mv /etc/apt/sources.list /etc/apt/sources.list.bak

建立一個新檔案:

touch /etc/apt/sources.list

修改檔案許可權:

chmod 777 /etc/apt/sources.list

在檔案中加入下面的內容,將源改為阿里的源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

儲存退出

輸入命令更換

sudo apt update

2.使用apt進行mysql服務的安裝

sudo apt-get install mysql-server

在安裝過程中可能需要輸入兩次你的mysql密碼

 安裝完成

3.常用的mysql命令

檢視mysql狀態:sudo service mysql status
啟動mysql服務:sudo service mysql start
停止mysql服務:sudo service mysql stop
重啟mysql服務:sudo service mysql restart

4.修改mysql配置檔案,可以遠端連線

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

 改成 

bind-address = 0.0.0.0

5.修改忽略表名的大小寫

在centos上沒有遇到過這個問題,在ubuntu16和ubuntu18上都遇到了這個問題

show variables like "%case%";
Lower_case_file_System OFF 說明當前表名區分大小寫
在配置檔案增加下面一行命令
cd /etc/mysql/mysql.conf.d
lower_case_table_names=1

6.設定許可權,可以進行遠端登入

輸入: mysql -uroot -p

輸入你的密碼進入mysql客戶端

 遠端命令設定

grant all on *.* to root@'%' identified by '你的密碼' with grant option;
重新整理
flush privileges;
退出
exit

重啟mysql: 

service mysql restart

7.使用navicat進行連線測試

 到此,mysql 的安裝配置完成。