查看CentOS自带mysql是否已安裝:
yum list installed | grep mysql
7 z4 t( s! O7 U% `; ?6 s6 v若有自带安装的mysql,如何卸载CentOS系统自带mysql資料庫?
yum -y remove mysql-libs.x86_64,若有多個依賴文件则依次卸載。
J6 Z0 u$ Q! }2 x查看yum庫上的mysql版本信息:
yum list | grep mysql 或 yum -y list mysql*
; s, o# {2 g3 Q+ q! d: j* P使用yum安装mysql資料庫:
yum -y install mysql-server mysql mysql-devel
注:安装mysql只是安装了資料庫,只有安装mysql-server才相當于安装了server及client。
- |' {) e3 L% _" W- y6 ]假如輸入 mysql 出現 error:
rpm -qi mysql-server
設定 /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql: R2 I+ v& Y5 b0 x8 ^
socket=/var/lib/mysql/mysql.sock' [4 l% \# z5 h; |, \
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1& h D% z1 I; s7 G7 [
default-character-set = utf8( I7 E) E$ }. W' `8 Q. @7 _. S
# [5 K2 T" D, z, }" f: F
[mysql.server]6 y9 E, ^! C% b( F: S
user=mysql
basedir=/var/lib+ Y9 A& i& D: E5 C
2 ~1 t: S: t0 Z% s; ^4 L7 G5 |
[mysqld_safe]) q& M& q3 U- M" j& v4 D5 Z
log-error=/var/log/mysqld.log. i5 P+ b3 o! e0 m; m. M
pid-file=/var/run/mysqld/mysqld.pid
9 t/ J' ?, }+ o% ]
[mysql]
default-character-set = utf81 E# s0 L* q( n: _2 H/ Y6 t( l3 ?
設定 MySQL 服務隨系統一起啟動
# chkconfig mysqld on
$ `7 t5 |; _) h0 x. W& V. _; m
確認 MySQL 自動啟動有打開8 a0 x, {# B( A2 O1 A
# chkconfig --list mysqld4 U/ B1 Q/ A& K$ [+ y
如果2--5為on的狀態就OK2 n/ `: K5 P: l# T. Z) ^7 E
mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off4 T# V, s" K2 L
啟動 MySQL 服務6 L3 e2 o9 B( g3 t2 |8 r& f3 D
# 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
啟動 MySQL 以後,必須設定 root 的密碼0 U$ U. `3 @4 `6 H4 v9 @1 b
# 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
輸入密碼
+ f# K: r l$ V, u9 ?
[重新安裝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/mysql160414 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 exist160414 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 disabled160414 10:07:57 InnoDB: Mutexes and rw_locks use InnoDB's own implementation160414 10:07:57 InnoDB: Compressed tables use zlib 1.2.3160414 10:07:57 InnoDB: Using Linux native AIO160414 10:07:57 InnoDB: Initializing buffer pool, size = 128.0M160414 10:07:57 InnoDB: Completed initialization of buffer pool160414 10:07:57 InnoDB: highest supported file format is Barracuda.160414 10:07:57 InnoDB: Waiting for the background threads to start160414 10:07:58 InnoDB: 5.5.49 started; log sequence number 1595675160414 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: 3306160414 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) w8 d& d5 o# V3 g: I2 z2 W
mysql_install_db --user=mysql --ldata=/var/lib/mysql/ ===>check /var/lib/mysql/內已建立許多DB. T* \) n# e% A( ~; r4 a2 q
/ _# ~+ E: [4 _- m
升級成最新版:
https://www.cadch.com/modules/news/article.php?storyid=227
| 歡迎光臨 52AV手機A片王|52AV.ONE (https://www.52av.one/) | Powered by Discuz! X3.2 |