ubuntu下mysql安裝(server、client、dev),開啟、停止和重啟,及常見錯誤

來源:互聯網
上載者:User

標籤:c語言開發   service   ubuntu   mysql   server   

1. 在ubuntu下安裝server和client很簡單:

(1)安裝server

apt-get install mysql-server

安裝當中,會提示輸入root賬戶的密碼,按提示輸入即可。

安裝後預設開啟了server

(2) 安裝client

apt-get install mysql-client

 

2. 安裝mysql的c語言開發介面

apt-get install libmysqlclient15-dev

 

3. 開啟、關閉、重啟

一、啟動

1、使用 service 啟動:service mysqld start

2、使用 mysqld 指令碼啟動:/etc/inint.d/mysqld start ,或者/etc/inint.d/mysql start

3、使用 safe_mysqld 啟動:safe_mysqld&

二、停止

1、使用 service 啟動:service mysqld stop

2、使用 mysqld 指令碼啟動:/etc/inint.d/mysqld stop,或者/etc/inint.d/mysql stop

3、mysqladmin shutdown

三、重啟

1、使用 service 啟動:service mysqld restart

2、使用 mysqld  指令碼啟動:/etc/inint.d/mysqld restart,或者/etc/inint.d/mysql restart

 

下面四句雖然很簡單,但卻很實用!(未嘗試過)

net stop mssqlserver
net start mssqlserver

net stop mysql
net start mysql

 

往往也會使用:

/usr/sbin/mysqld  restart(stop/start)

 

 

4. 常見問題:

(一)ERROR2002:

 1) 主要是因為server沒有啟動的原因;

 2)或者是在/etc/mysql/my.cnf檔案(或用locate my.cnf搜尋該檔案位置)中注釋掉bind-address 127.0.0.1(禁止遠端存取,只允許本地訪問);

 3)然後在mysql中使用GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION; FLUSH   PRIVILEGES; 目的是在改mysql-server上允許任何的機器(%)以使用者名稱(myuser)及密碼(mypassword)來串連到該serve上;

再在mysq中,輸入:

mysqll>use mysql;

mysql>select host,user from user;

應該會出現類似以下的結果:     

+-----------+------------------+

| host     | user                 |

+-----------+------------------+

| %        | root                  |

| 127.0.0.1 | root             |

| c2-1     | root                 |

| localhost | debian-sys-maint |

| localhost | root             |

+-----------+------------------+

%表明了已經授權給了遠端存取的任何機器。

這樣基本上就可以解決問題了。

 

(二)ERROR 2003:基本上是與網路有關,看看路由對不對!

初學的mysql網友好象經常會碰到mysql無法串連的錯誤。特開貼收集這樣問題的現象和原因。

先自己扔塊磚頭出來。

===========================================================================================
故障現象 : 無法串連 mysql 
錯誤資訊 :ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘hostxxxxx‘ (10061)
原因 : mysqld資料庫服務沒有啟動。
檢查 :在windows 的工作管理員,或者 unix/linux 下 ps -aux | grep mysql 看一下。確認服務已經啟動。
處理 :啟動mysqld 服務
===========================================================================================

ubuntu下mysql安裝(server、client、dev),開啟、停止和重啟,及常見錯誤

聯繫我們

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