Linux(CentOS 6.5)安裝 mysql,centosmysql

來源:互聯網
上載者:User

Linux(CentOS 6.5)安裝 mysql,centosmysql

linux下安裝軟體的方式很多,這裡是使用簡單而方便的yum來安裝

一、使用yum 安裝mysql服務,用戶端

1、檢查是否已經安裝: yum  list installed | grep mysql

2、 yum list installed | grep MYSQL

3、查詢結果:


4、這是我已經安裝的mysql ,我們可以使用yum  提供的remove方法刪除這些已經安裝的mysql 以及相關軟體: yum -y remove packageName

5、刪除已有的軟體後進行安裝,安裝mysql用戶端: yum  install  packageName(mysql)

6、安裝mysql服務端:yum  install mysql-server

7、安裝devel: yum install mysql-devel

到這裡mysql已經安裝完了,但之後啟動什麼的肯定還有問題 接下來就看看

二、mysql各種屬性配置

1、字元集編碼設定,mysql安裝之後其設定檔在 vim /etc/my.cnf開啟之後在【mysqld】下添加:default-character-set=utf-8

2、啟動mysql 服務: service mysqld  start 或 /etc/init.d/mysqld start

3、查看mysql的開機啟動設定: chkconfig  --list | grepmysql


4、你的有可能都是off,這時要添加屬性:

Chkconfig  mysqld on  #設定mysqld在各等級為on,“各等級”包括2、3、4、5等級

5、你自己也可以指定等級: chkconfig --level 35 mysql on,以init 35的等級登陸時mysql服務自動啟動

6查看你的設定是否成功: chkconfig --list | grep mysql

7、停止服務: service  mysqld stop 或/etc/init.d/mysqld stop

 

  到這裡安裝設定完成了,我們就進行登陸,但登陸可能也不順利看看:

三、client 訪問服務端的問題

1、mysql -uroot password 123456

  • 可能報 ERROR 2002  Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 這樣的錯誤

原因:

(1) 沒啟動服務

(2)在 vim /etc/my.cnf 中添加如下資訊:

[client]

socket=/var/lib/mysql/mysql.sock

從vim的扁家模式退出 並將編譯器緩衝中的資料寫到 my.cnf設定檔中儲存退出

2、mysql -uroot -p 直接斷行符號

(1)、可能成功的進入到 mysql

(2)、報錯,你沒有許可權,因為你還沒建立使用者什麼的說以不行:

解決1:

[1] 在 vim  /etc/my.cnf的mysqld下添加 skip-grant-tables(跳過表單許可權,沒有密碼可以直接進入 mysql 模式)

[2]進入mysql 模式後 update user  setpassword=password("you password") where user ='root';

[3] quit; 退出  service mysqld  restart 然後再mysql  應該就o了!

 

解決2:

[1]service mysqldstop

[2]mysqld_safe--skip-grant-tables & mysql -uroot -p 斷行符號進入

[3]use mysql;

[4] update userset password=password("newpass")whereuser="root";  #更改密碼為 newpassord

[5] flushprivileges;   #更新許可權

[6] quit 退出

[7]service mysqldrestart

mysql -uroot -p新密碼進入

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.