MySql下載地址http://mirrors.sohu.com/mysql/
1.rpm安裝,安裝MySQL時出現不兼容
# rpm -ivh MySQL-server-5.5.52-1.linux2.6.x86_64.rpm
Preparing... ################################# [100%]
file /usr/share/mysql/charsets/README from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.5.52-1.linux2.6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
……
解決:# yum remove mysql-libs
2.安裝過程中出現
warning: MySQL-server-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:MySQL-server-5.5.52-1.linux2.6 ################################# [100%]
error: unpacking of archive failed on file /usr/bin/myisampack;57ea0f54: cpio: read failed - No such file or directory
error: MySQL-server-5.5.52-1.linux2.6.x86_64: install failed
解決:可能是下載過程中文件被修改或者缺失,centOS有圖形界面,所以我是直接從Windows上粘貼複製過去的,後來用rz上傳,就沒問題了
3.如果已安裝過MySql
檢查一下:# rpm -qa | grep MySQL
MySQL-server-5.0.27-0.glibc23
然後,
# rpm -e --nodeps MySQL-server-5.0.27-0.glibc23
不行的話可以用#rpm -e --allmatches MySQL-server-5.0.27-0.glibc23 搞定。再
# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql
mysql的相關文件應該可以手動刪除了 示例 rm -rf /var/lib/mysql
mysql啓動:/etc/init.d/mysql start
mysql停止:/usr/bin/mysqladmin -u root -p shutdown
rpm命令參數: --force忽略軟件包及文件的衝動
--nodeps 不檢查依賴性關係
--dbpath設置RPM資料庫所在的路徑
--prefix 將軟件包安裝到由指定的目錄下
4.mysql的幾個重要目錄
# /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; mysql> FLUSH PRIVILEGES; mysql> quit # /etc/init.d/mysql restart # mysql -uroot -p Enter password: <輸入新設的密碼newpassword>
6.獲取mysql的安裝路徑
which mysqld
7.查看mysql的默認配置信息
通過上面的安裝路徑 加--verbose --help 來查看
如 /usr/local/mysql/bin/mysqld --verbose --help
8.查找mysql使用的my.cnf文件路徑
/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'
執行結果如下
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/mysql/etc/my.cnf ~/.my.cnf
系統默認是按/etc/my.cnf-----/etc/mysql/my.cnf----/usr/local/mysql/my.cnf的順序讀取配置文件的,當有多個配置文件時,mysql會以讀取到的最後一個配置文件中的參數爲準。