linux下安裝mysql

來源:互聯網
上載者:User

標籤:fedora   x86_64   rem   檢測   檢查   注意   top   tor   conf   

1.1. 檢測是否已經安裝了mysql

rpm -qa | grep mysql   

如果已經安裝了,將其卸載,如:

rpm -e --nodeps  mysql-libs-5.1.71-1.el6.x86_64

1.2. 安裝mysql

1、mkdir /usr/local/src/mysql

2、cd /usr/local/src/mysql

3、tar -xvf MySQL-5.6.22-1.el6.i686.rpm-bundle.tar(解壓)

4、安裝server
rpm -ivh MySQL-server-5.6.22-1.el6.i686.rpm
出錯:

安裝依賴:yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6 

 

需要升級libstdc++-4.4.7-4.el6.x86_64
yum  update libstdc++-4.4.7-4.el6.x86_64

5、安裝中:

 

6、安裝client

安裝依賴:yum -y install libncurses.so.5 libtinfo.so.5

7、查詢mysq服務運行狀態

服務未啟動。

8、 啟動mysql服務
service mysql start

9、使用root帳號登入mysql
提示:

在安裝mysql server時有句提示:

1、 注意:這個密碼是不安全的,所有需要修改初始密碼。

2、 使用密碼登入mysql帳號:mysql -uroot -p

3、 修改root密碼:SET PASSWORD = PASSWORD(‘123456‘);

2.3  系統啟動時自動啟動mysql服務

注意:

centos7開始使得以往老版本系統服務的/etc/init.d的啟動指令碼的方式就此改變,在centos7中所有對服務的管理都集中到了systemctl當中。
systemctl是一個系統管理守護進程、工具和庫的集合,用於取代以往的System V、service和chkconfig命令。

建立用於啟動MySQL的設定檔
[[email protected] ~]# touch /usr/lib/systemd/system/mysqld.service
[[email protected] ~]# cd /usr/lib/systemd/system

編輯mysqld.service檔案,加入如下內容:
[[email protected] system]# vi mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/opt/mysql-5.7.18/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
儲存退出

備忘:ExecStart=/opt/mysql-5.7.18/bin/mysqld (此處請對應修改為MySQL程式所在的路徑)
尋找mysqld路徑,例如:
[[email protected] system]# which mysqld
/opt/mysql-5.7.18/bin/mysqld

通過systemctl方式啟動mysql5.7:
[[email protected] system]# systemctl start mysqld

檢查MySQL運行狀態:
[[email protected] system]# mysql -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18-log MySQL Community Server (GPL)

關閉防火牆:
[[email protected] system]# systemctl stop firewalld.service
[[email protected] system]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

設定mysql的開機啟動:
[[email protected] system]# systemctl enable mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[[email protected] system]# systemctl list-unit-files | grep mysqld
mysqld.service                                enabled 

取消mysql的開機自啟動:
[[email protected] system]# systemctl disable mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/mysqld.service.
[[email protected] system]# systemctl list-unit-files | grep mysqld
mysqld.service                                disabled

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.