linux安裝mysql

來源:互聯網
上載者:User

標籤:執行   使用者   open   ide   usr   mysql使用者   gre   ima   yum   

1、下載

    :http://dev.mysql.com/downloads/mysql/5.6.html#downloads

    下載版本:我這裡選擇的5.6.33,通用版,linux下64位

    也可以直接複製64位的,通過命令下載:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

2,解壓縮

#解壓

tar  -zxvf mysql-5.6.33-linux-glibc2.5-x86_64. tar .gz #複製解壓後的mysql目錄 cp  -r mysql-5.6.33-linux-glibc2.5-x86_64  /usr/local/mysql

3、添加使用者組和使用者

#添加使用者組

groupadd mysql #添加使用者mysql 到使用者組mysql useradd  -g mysql mysql4,安裝mysql

進入安裝mysql軟體目錄:執行命令 cd /usr/local/mysql

修改目前的目錄擁有者為mysql使用者:執行命令chown -R mysql:mysql ./

安裝資料庫:執行命令./scripts/mysql_install_db --user=mysql

修改目前的目錄擁有者為root使用者:執行命令chown -R root:root ./

修改當前data目錄擁有者為mysql使用者:執行命令chown -R mysql:mysql data

到此資料庫安裝完畢

 

啟動mysql服務和添加開機啟動mysql服務:

添加開機啟動:執行命令cp support-files/mysql.server /etc/init.d/mysql,把啟動指令碼放到開機初始化目錄

啟動mysql服務:執行命令service mysql start

執行命令:ps -ef|grep mysql 看到mysql服務說明啟動成功,

修改mysql的root使用者密碼,root初始密碼為空白的:

執行命令:./bin/mysqladmin -u root password ‘密碼‘

把mysql用戶端放到預設路徑:

ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

 

安裝過程遇到的錯誤

-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 沒有那個檔案或目錄
    解決: yum -y install perl perl-devel

Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
    解決:yum -y install libaio-devel

                         yum -y install numactl

給使用者授權

2. 授權法。

例如,你想myuser使用mypassword從任何主機串連到mysql伺服器的話。

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;

FLUSH   PRIVILEGES;

                        

linux安裝mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.