in header_common.htm --> -->

52AV手機A片王|52AV.ONE

 找回密碼
 立即註冊
快捷導航

Yahoo!奇摩搜尋
熱搜: 手機A片
Google奇摩搜尋
熱搜: 手機A片
     
查看: 3193|回復: 0
打印 上一主題 下一主題

[mysql] CentOS使用yum安裝mysql

[複製鏈接]
跳轉到指定樓層
樓主
發表於 2015-10-30 17:31:21 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式


查看CentOS自带mysql是否已安裝:

yum list installed | grep mysql

0 c8 {- X4 e' W  d0 j7 V; w4 S

若有自带安装的mysql,如何卸载CentOS系统自带mysql資料庫?

mysql-libs.x86_64       5.1.73-5.el6_6  @anaconda-CentOS-201508042137.x86_64/6.7

yum -y remove mysql-libs.x86_64,若有多個依賴文件则依次卸載。

2 z# R. j5 X' D0 x

查看yum庫上的mysql版本信息:

yum list | grep mysql 或 yum -y list mysql*

5 `9 {$ A6 _# Y8 y3 D0 c& L- E9 e8 `

使用yum安装mysql資料庫:

yum -y install mysql-server mysql mysql-devel

注:安装mysql只是安装了資料庫,只有安装mysql-server才相當于安装了server及client。


! e& [- Z( m, y- i

假如輸入 mysql  出現 error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)      表示未啟動 mysqld
所以輸入  service mysqld start,啟動後馬上出現以下訊息,提醒你的一些有用的訊息:
  1. To start mysqld at boot time you have to copy
  2. support-files/mysql.server to the right place for your system
  3. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  4. To do so, start the server, then issue the following commands:
  5. /usr/bin/mysqladmin -u root password 'new-password'
  6. /usr/bin/mysqladmin -u root -h video.yocoolnet.com password 'new-password'
  7. Alternatively you can run:
  8. /usr/bin/mysql_secure_installation
  9. which will also give you the option of removing the test
  10. databases and anonymous user created by default.  This is
  11. strongly recommended for production servers.
  12. See the manual for more instructions.
  13. You can start the MySQL daemon with:
  14. cd /usr ; /usr/bin/mysqld_safe &
  15. You can test the MySQL daemon with mysql-test-run.pl
  16. cd /usr/mysql-test ; perl mysql-test-run.pl
複製代碼
查看刚安装mysql数据库版本信息:

rpm -qi mysql-server

) I' Z* Q$ [! c; s+ I

設定 /etc/my.cnf
/ o* J2 u! D# }$ a! O, m

[mysqld]
1 b% _4 D! d2 K% k/ Z3 H, _datadir=/var/lib/mysql$ z: r6 Q- X( m0 q$ r0 h0 ?& Q
socket=/var/lib/mysql/mysql.sock
, T' I+ m9 k4 d8 [# Default to using old password format for compatibility with mysql 3.x
' C! G5 p/ \9 r$ Z9 {$ `/ `; B# clients (those using the mysqlclient10 compatibility package).& T! m+ z3 T2 v  Q6 m/ S* E* {3 w7 F0 s
old_passwords=1
0 T8 ^/ A# D; s" u4 L9 Ldefault-character-set = utf8, B8 C& S( J) f' h9 A3 c" s9 a0 K
- K5 Z: M, Z9 y4 l0 ]6 ?# ~
[mysql.server]
. h2 E2 N9 F' I- Y# s2 a  vuser=mysql
/ j& B" q  c3 ~( R% P; @basedir=/var/lib
2 T" |7 O: f" S, a* i1 `+ Y* |* `1 E, h6 M. I5 `6 E/ }% H9 T  O
[mysqld_safe]
2 n" O0 B' U* L- Ulog-error=/var/log/mysqld.log
* z2 g% S5 G4 ~" W" a" @6 ~. _pid-file=/var/run/mysqld/mysqld.pid* q5 p4 j! O6 _/ Y2 Y& U4 h1 \% D' D

3 q* c; H; C; z: L, H[mysql]$ V# [( E" A4 i% G
default-character-set = utf89 }" {+ ]) C  Z6 P5 W

設定 MySQL 服務隨系統一起啟動  ]0 J  H- D) t) |: f
# chkconfig mysqld on
6 n% n! t5 v" C) H2 I' {; s6 @7 S7 P' p0 I
確認 MySQL 自動啟動有打開
- j% j5 y6 a) \  \( H

# chkconfig --list mysqld( I+ c) @7 L5 R! Z. x

如果2--5為on的狀態就OK/ z; K9 r/ m* u. Q0 P

mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off& s/ w- C) j8 B0 R

啟動 MySQL 服務
2 T  ]  g8 g  ~

# service mysqld start   或 /usr/bin/mysqld_safe &
確認 MySQL 是否已啟動
#service mysqld status
mysqld (pid  33778) is running...
cd /usr/mysql-test ; perl mysql-test-run.pl

' S) k7 P0 W9 t% l

啟動 MySQL 以後,必須設定 root 的密碼% L5 b. M& o. a, w! D' E

# mysqladmin -u root password 'Your Password'    或者執行指令
# /usr/bin/mysql_secure_installation
試 root 是否可成功登入 mysql:
mysql -u root -p
Enter password:   (輸入root 密碼)
升級 MySQL database至最新
# mysql_upgrade -u root -p
輸入密碼
# M% r" v+ y( D8 G$ F
[重新安裝mysql]
參考http://tecadmin.net/remove-mysql-completely-from-linux-system/
註:
以yum安裝在CentOS 5.11/i386 啟動時出現錯誤,see /var/log/mysqld.log :
160414 10:07:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160414 10:07:57 [Note] /usr/libexec/mysqld (mysqld 5.5.49) starting as process 9426 ...
160414 10:07:57 [Note] Plugin 'FEDERATED' is disabled.
/usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist
160414 10:07:57 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
160414 10:07:57 InnoDB: The InnoDB memory heap is disabled
160414 10:07:57 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
160414 10:07:57 InnoDB: Compressed tables use zlib 1.2.3
160414 10:07:57 InnoDB: Using Linux native AIO
160414 10:07:57 InnoDB: Initializing buffer pool, size = 128.0M
160414 10:07:57 InnoDB: Completed initialization of buffer pool
160414 10:07:57 InnoDB: highest supported file format is Barracuda.
160414 10:07:57  InnoDB: Waiting for the background threads to start
160414 10:07:58 InnoDB: 5.5.49 started; log sequence number 1595675
160414 10:07:58 InnoDB: !!! innodb_force_recovery is set to 1 !!!
160414 10:07:58 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
160414 10:07:58 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
160414 10:07:58 [Note] Server socket created on IP: '0.0.0.0'.
160414 10:07:58 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
原因是:啟動mysqld時無法自動建立 /var/lib/mysql/所有資料庫,因此需手動建立所有DB# d- `2 c, c* N
mysql_install_db --user=mysql --ldata=/var/lib/mysql/  ===>check /var/lib/mysql/內已建立許多DB
8 i" D! d5 ^4 ^: s5 S* M

- e2 j; U; Y! i
升級成最新版:
https://www.cadch.com/modules/news/article.php?storyid=227
-->
您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則


-->

聚BT福利

本區塊內容依據『電腦網路內容分級處理辦法』為限制級網站,限定年滿18歲以上或達當地國家法定年齡人士方可進入,且願接受本站各項條款,未滿18歲 謝絕進入瀏覽。為防範未滿18歲之未成年網友瀏覽網路上限制級內容的圖文資訊,建議您可進行網路內容分級組織ICRA分級服務的安裝與設定。 (為還給愛護 本站的網友一個純淨的論壇環境,本站設有管理員)

QQ|小黑屋|手機板|52AV手機A片王

GMT+8, 2024-10-7 02:55 , Processed in 0.070427 second(s), 20 queries .

連絡站長.廣告招商

[email protected] | QQ:2405733034     since 2015-01

裸聊妹 快速回復 返回頂部 返回列表