總結下mysql rpm安裝的方式,與一些錯誤 環境[root@host2 ~]# uname -aLinux host2 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/L ...
總結下mysql rpm安裝的方式,與一些錯誤
環境
[root@host2 ~]# uname -a
Linux host2 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@host2 ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
1,檢查是否安裝
[root@host2 ~]# rpm -qa | grep --color mysqlMySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle.tar
2,刪除已安裝
[root@host2 ~]# rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
[root@host2 ~]#
3,查驗,這樣刪還是會留下一些東西
[root@host2 ~]# find / -name mysql
[root@host2 ~]# find / -name *mysql*
/etc/selinux/targeted/modules/active/modules/mysql.pp
/usr/lib/python2.6/site-packages/sos/plugins/mysql.pyc
/usr/lib/python2.6/site-packages/sos/plugins/mysql.pyo
/usr/lib/python2.6/site-packages/sos/plugins/mysql.py
/usr/share/vim/vim72/syntax/mysql.vim
/usr/share/selinux/devel/include/services/mysql.if
/usr/share/selinux/targeted/mysql.pp.bz2
/usr/share/doc/rsyslog-5.8.10/rsyslog_mysql.html
/usr/share/doc/rsyslog-5.8.10/ommysql.html
/usr/share/man/man5/mysql_table.5.gz
/usr/lib64/libreoffice/program/libmysqllo.so
/selinux/booleans/allow_user_mysql_connect
/selinux/booleans/mysql_connect_any
/var/lib/yum/yumdb/m/b642f65e3df41063e068158061ae2e08f22e3dad-mysql-libs-5.1.71-1.el6-x86_64
保證下麵安裝順利,最好是將這些文件都刪除
4,查驗有否mysql用戶和組
[root@host2 ~]# nl /etc/group | grep mysql
[root@host2 ~]# nl /etc/shadow | grep mysql
5,解包
[root@host2 mysql_rpm]# tar -xvf MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle.tar
MySQL-shared-compat-5.6.22-1.linux_glibc2.5.x86_64.rpm #RHEL相容包
MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm #MySQL客戶端程式
MySQL-shared-5.6.22-1.linux_glibc2.5.x86_64.rpm #MySQL的共用庫
MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm #MySQL服務端程式
MySQL-test-5.6.22-1.linux_glibc2.5.x86_64.rpm #MySQL的測試組件
MySQL-devel-5.6.22-1.linux_glibc2.5.x86_64.rpm #MySQL的庫和頭文件
MySQL-embedded-5.6.22-1.linux_glibc2.5.x86_64.rpm #MySQL的嵌入式程式
6,安裝,會自動初始化資料庫
[root@host2 mysql_rpm]# rpm -ivh MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm Preparing... ########################################### [100%] 1:MySQL-server ########################################### [100%] warning: user mysql does not exist - using root warning: group mysql does not exist - using root 2015-01-20 13:10:42 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2015-01-20 13:10:42 5645 [Note] InnoDB: Using atomics to ref count buffer pool pages 2015-01-20 13:10:42 5645 [Note] InnoDB: The InnoDB memory heap is disabled 2015-01-20 13:10:42 5645 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2015-01-20 13:10:42 5645 [Note] InnoDB: Memory barrier is not used 2015-01-20 13:10:42 5645 [Note] InnoDB: Compressed tables use zlib 1.2.3 2015-01-20 13:10:42 5645 [Note] InnoDB: Using Linux native AIO 2015-01-20 13:10:42 5645 [Note] InnoDB: Not using CPU crc32 instructions 2015-01-20 13:10:42 5645 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2015-01-20 13:10:42 5645 [Note] InnoDB: Completed initialization of buffer pool 2015-01-20 13:10:42 5645 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 2015-01-20 13:10:42 5645 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 2015-01-20 13:10:42 5645 [Note] InnoDB: Database physically writes the file full: wait... 2015-01-20 13:10:42 5645 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 2015-01-20 13:10:42 5645 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 2015-01-20 13:10:43 5645 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2015-01-20 13:10:43 5645 [Warning] InnoDB: New log files created, LSN=45781 2015-01-20 13:10:43 5645 [Note] InnoDB: Doublewrite buffer not found: creating new 2015-01-20 13:10:43 5645 [Note] InnoDB: Doublewrite buffer created 2015-01-20 13:10:43 5645 [Note] InnoDB: 128 rollback segment(s) are active. 2015-01-20 13:10:43 5645 [Warning] InnoDB: Creating foreign key constraint system tables. 2015-01-20 13:10:43 5645 [Note] InnoDB: Foreign key constraint system tables created 2015-01-20 13:10:43 5645 [Note] InnoDB: Creating tablespace and datafile system tables. 2015-01-20 13:10:43 5645 [Note] InnoDB: Tablespace and datafile system tables created. 2015-01-20 13:10:43 5645 [Note] InnoDB: Waiting for purge to start 2015-01-20 13:10:43 5645 [Note] InnoDB: 5.6.22 started; log sequence number 0 A random root password has been set. You will find it in '/root/.mysql_secret'. 2015-01-20 13:10:44 5645 [Note] Binlog end 2015-01-20 13:10:44 5645 [Note] InnoDB: FTS optimize thread exiting. 2015-01-20 13:10:44 5645 [Note] InnoDB: Starting shutdown... 2015-01-20 13:10:45 5645 [Note] InnoDB: Shutdown completed; log sequence number 1625977 2015-01-20 13:10:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2015-01-20 13:10:45 5667 [Note] InnoDB: Using atomics to ref count buffer pool pages 2015-01-20 13:10:45 5667 [Note] InnoDB: The InnoDB memory heap is disabled 2015-01-20 13:10:45 5667 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2015-01-20 13:10:45 5667 [Note] InnoDB: Memory barrier is not used 2015-01-20 13:10:45 5667 [Note] InnoDB: Compressed tables use zlib 1.2.3 2015-01-20 13:10:45 5667 [Note] InnoDB: Using Linux native AIO 2015-01-20 13:10:45 5667 [Note] InnoDB: Not using CPU crc32 instructions 2015-01-20 13:10:45 5667 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2015-01-20 13:10:45 5667 [Note] InnoDB: Completed initialization of buffer pool 2015-01-20 13:10:45 5667 [Note] InnoDB: Highest supported file format is Barracuda. 2015-01-20 13:10:45 5667 [Note] InnoDB: 128 rollback segment(s) are active. 2015-01-20 13:10:45 5667 [Note] InnoDB: Waiting for purge to start 2015-01-20 13:10:45 5667 [Note] InnoDB: 5.6.22 started; log sequence number 1625977 2015-01-20 13:10:45 5667 [Note] Binlog end 2015-01-20 13:10:45 5667 [Note] InnoDB: FTS optimize thread exiting. 2015-01-20 13:10:45 5667 [Note] InnoDB: Starting shutdown... 2015-01-20 13:10:47 5667 [Note] InnoDB: Shutdown completed; log sequence number 1625987 A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find that password in '/root/.mysql_secret'. You must change that password on your first connect, no other statement but 'SET PASSWORD' will be accepted. See the manual for the semantics of the 'password expired' flag. Also, the account for the anonymous user has been removed. In addition, you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test database. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems at http://bugs.mysql.com/ The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /usr/my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings
7,RPM安裝方式文件分佈
Table 2.6 MySQLInstallation Layout for Linux RPM Packages from the MySQL DeveloperZone
Directory | Contentsof Directory |
---|---|
/usr/bin | Clientprograms and scripts |
/usr/sbin | Themysqldserver |
/var/lib/mysql | Logfiles, databases |
/usr/share/info | Manualin Info format |
/usr/share/man | Unixmanual pages |
/usr/include/mysql | Include(header) files |
/usr/lib/mysql | Libraries |
/usr/share/mysql | Miscellaneoussupport files, including error messages, character set files,sample configuration files, SQL for database installation |
/usr/share/sql-bench | Benchmarks |
8,copy配置文件
# 沒有這一步也可以按內置參數
[root@host2 mysql_rpm]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
9,啟動mysql
[root@host2 mysql_rpm]# service mysql status
MySQL is not running [FAILED]
[root@host2 mysql_rpm]# service mysql start
Starting MySQL.. [ OK ]
10,檢查進程
[root@host2 mysql_rpm]# netstat -anpl | grep mysql
tcp 0 0 :::3306 :::* LISTEN 5924/mysqld
unix 2 [ ACC ] STREAM LISTENING 76015 5924/mysqld /var/lib/mysql/mysql.sock
11,安裝客戶端
[root@host2 mysql_rpm]# rpm -ivh MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
12,連到mysql並修改
[root@host2 mysql_rpm]# nl /root/.mysql_secret
1 # The random password set for the root user at Tue Jan 20 13:10:43 2015 (local time): F76Wy1A4G9ZuLcaG ---這是初次登錄mysql,root的密碼
[root@host2 mysql_rpm]# mysql -p mysql Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.22 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; ERROR 1820 (HY000): You must SET PASSWORD before executing this statement mysql> mysql> SET PASSWORD = PASSWORD('123456'); Query OK, 0 rows affected (0.31 sec) mysql> flush privileges; mysql> \q Bye
在啟動過程中,曾遇到這個錯誤(The server quit without updating PID file),相信許多人應該也遇到過,做下總結:
原因:在MySQL的datadir數據目錄下沒有pid文件或者未被授權
解決方式:
(1)一定要給譬如/data/mysql授權
chown -R mysql:mysql /data/mysql
(2)如果授權了不好使,你可以自己在/data/mysql下建立一個以主機名命名的pid,如我的主機名是centos-6.3
你可以cd /data/mysql && touch centos-6.3.pid
在裡面隨意寫一個進程中沒有的pid號
(3)如果還是不行,你就需要看看配置文件/etc/my.cnf裡面的配置了,將port、datadir、basedir、 socket前的#去掉
(4)另外的處理方法還有可能是下麵的原因導致
1>可能是第二次在機器上安裝mysql,有殘餘數據影響了服務的啟動。
解決方法:去mysql的數據目錄/data看看,如果存在mysql-bin.index,就趕快把它刪除掉吧,它就是罪魁禍首了
2>mysql在啟動時沒有指定配置文件時會使用/etc/my.cnf配置文件,請打開這個文件查看在[mysqld]節下有沒有指定數據目錄(datadir)。
解決方法:請在[mysqld]下設置這一行:datadir = /usr/local/mysql/data
3>skip-federated欄位問題
解決方法:檢查一下/etc/my.cnf文件中有沒有沒被註釋掉的skip-federated欄位,如果有就立即註釋掉吧。
4>selinux惹的禍,如果是centos系統,預設會開啟selinux(今天遇到的錯誤就是這個)
解決方法:關閉它,打開/etc/selinux/config,把SELINUX=enforcing改為SELINUX=disabled後存檔退出重啟機器試試。