首先,linux下有多種方法,①為編譯的,②編譯的tar.gz包,③,編譯的rpm;本文打算敘述rpm形式的安裝過程:后邊將書tar.gz包的安裝及一些問題的解決參考
一、下載安裝包
MySQL-server-5.7.4_m14-1.el6.x86_64.rpm MySQL-client-5.7.4_m14-1.el6.x86_64.rpm
二、檢查與清理原來是否有安裝殘留
如果確信沒有安裝過mysql服務就不用了,如果是重裝或者不確定可以逐級查看
如果有用yum安裝過使用命令: yum remove mysql* 卸載
然后刪除mysql舊有的文件和文件夾殘留或者數據,:
rm - rf mysql****
殺死mysqld進程 kill -9 mysqld
特別注意:/etc/my.cnf文件、/usr/bin、/usr/share下的mysql相關的文件也要一並刪除,此外還有安裝過程中的/etc/init.d/mysql配置文件的刪除
三、安裝rpm包及解決可能出現的依賴
安裝一中下載的rpm文件,先安裝server.prm 文件,然后安裝 client.rpm文件
rpm -ivh 文件名.rpm
[root@localhost /]# rpm -ivh MySQL-server-5.7.4_m14-1.el6.x86_64.rpm
error: Failed dependencies:
net-tools is needed by MySQL-server-5.7.4_m14-1.el6.x86_64
學要解決net-tools依賴,可以參考:yum解決依賴關系,中的
YUM常見命令用法如下:
1.列出所有可更新的軟件清單,命令:yum check-update 軟件名稱
2.安裝所有更新軟件,命令:yum update 軟件名稱
3.僅安裝指定的軟件,命令:yum install 軟件名稱
4.列出所有可安裝的軟件清單,命令:yum list
5.用YUM安裝刪除軟件,命令:yum remove 軟件名稱
簡單使用: yum install net-tools 然后y同意即可,但是后便會有點小問題 看見Complete!才算是安裝 net-tools成功
后邊再執行 rpm -ivh xxx.rpm 后看見一堆沖突:
file /usr/share/mysql/charsets/README from install of MySQL-server-5.7.4_m14-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.47-1.el7_2.x86_64
……
file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.7.4_m14-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.47-1.el7_2.x86_64
很簡單,就是之前的文件沒有刪除干凈,重新檢查,刪除一下。
之前我自己用有用yum安裝過mariadb-libs-1:5.5.47-1.el7_2.x86_64,所以用上變得命令 yum remove mariadb-libs-1:5.5.47-1.el7_2.x86_64 刪除這個包mariadb-libs-1:5.5.47-1.el7_2.x86_64
然后再執行 rpm -ivh XXX
Preparing... ################################# [100%]
find: '/var/lib/mysql': No such file or directory
Updating / installing...
1:MySQL-server-5.7.4_m14-1.el6 ################################# [100%]
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.
留意上邊的修改密碼提示。
然后安裝client:
[root@localhost /]# rpm -ivh MySQL-client-5.7.4_m14-1.el6.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:MySQL-client-5.7.4_m14-1.el6 ################################# [100%]
四、設置密碼與簡單使用
查看服務是否啟動,即3306端口是否在啟動:netstat -nat
啟動服務:service mysql start
[root@localhost /]# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
[root@localhost /]# service mysql restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
還是原來的問題,還是原來的提示,這酸爽!!!
進入提示的文件夾,果然沒有那個pid文件,然后vim localhost.localdomain.err 查看問題沒有什么有用的信息。
簡直是,執行rpm -ql MySQL-server-5.7.4_m14-1.el6.x86_64.rpm
package MySQL-server-5.7.4_m14-1.el6.x86_64.rpm is not installed 顯示的是未安裝???
[root@localhost /]# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
查資料說有僵屍進程:參考 使用命令:ps -aux | grep mysqld 顯示如下:
root 2591 0.0 0.3 8984 808 pts/0 S+ 03:44 0:00 grep --color=auto mysqld
然后執行 ps -aux 的會看到個字段的意思。
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
殺掉進程:kill -9 進程號
但是還是啟動不了:第二中種沒用
終極tie 我想笑:丟失了pid怎么辦 最終自己新建了一個 /var/lib/mysql/localhost.localdomain.pid文件,里邊直接寫入 ps -aux | grep mysqld 讀到的pid值,保存就行。
[root@localhost mysql]# service mysql start
Starting MySQL SUCCESS!
然而:netstat -nat 還是查詢不到33006端口,再次啟動還是是失敗。
登錄:
五、卸載
------------
tar.gz形式的安裝。
一、下載安裝包
二、創建mysql用戶
三、安裝數據庫
[root@localhost sever]# cd mysql-5.7.11
[root@localhost mysql-5.7.11]# cd bin
[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data
2016-04-04 22:09:05 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-04-04 22:09:06 [ERROR] Child process: /usr/sever/mysql-5.7.11/bin/mysqldterminated prematurely with errno= 32
2016-04-04 22:09:06 [ERROR] Failed to execute /usr/sever/mysql-5.7.11/bin/mysqld --bootstrap --datadir=/home/mysql/data --lc-messages-dir=/usr/share/mysql --lc-messages=en_US --basedir=/home/mysql
-- server log begin --
2016-04-05T02:09:05.358823Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-04-05T02:09:05.359564Z 0 [Warning] Changed limits: max_open_files: 4096 (requested 5000)
2016-04-05T02:09:05.359573Z 0 [Warning] Changed limits: table_open_cache: 1967 (requested 2000)
2016-04-05T02:09:05.360209Z 0 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
-- server log end --
[root@localhost bin]# ./mysqld --user=mysql --basedir=/home/mysql/ --datadir=/home/mysql/data
2016-04-05T02:10:35.847170Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-05T02:10:35.847260Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2016-04-05T02:10:35.847293Z 0 [Note] ./mysqld (mysqld 5.7.11) starting as process 16732 ...
2016-04-05T02:10:35.847327Z 0 [ERROR] Can't find error-message file '/home/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2016-04-05T02:10:35.850131Z 0 [ERROR]
2016-04-05T02:10:35.850147Z 0 [ERROR] Couldn't load plugin named 'keyring_file' with soname 'keyring_file.so'.
2016-04-05T02:10:35.850690Z 0 [Note] InnoDB: PUNCH HOLE support not available
2016-04-05T02:10:35.850832Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-05T02:10:35.850842Z 0 [Note] InnoDB: Uses event mutexes
2016-04-05T02:10:35.850848Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2016-04-05T02:10:35.850852Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-04-05T02:10:35.850858Z 0 [Note] InnoDB: Using Linux native AIO
2016-04-05T02:10:35.851146Z 0 [Note] InnoDB: Number of pools: 1
2016-04-05T02:10:35.851259Z 0 [Note] InnoDB: Using CPU crc32 instructions
2016-04-05T02:10:35.860704Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-04-05T02:10:35.871080Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-04-05T02:10:35.873518Z 0 [ERROR] [FATAL] InnoDB: pthread_create returned 11
2016-04-04 22:10:35 0x7f7a8aa26740 InnoDB: Assertion failure in thread 140164288636736 in file ut0ut.cc line 920
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
02:10:35 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.
key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68188 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
./mysqld(my_print_stacktrace+0x35)[0xf45595]
./mysqld(handle_fatal_signal+0x4a4)[0x77fd34]
/lib64/libpthread.so.0(+0xf130)[0x7f7a8a606130]
/lib64/libc.so.6(gsignal+0x37)[0x7f7a892075d7]
/lib64/libc.so.6(abort+0x148)[0x7f7a89208cc8]
./mysqld[0x10dd465]
./mysqld(_ZN2ib5fatalD1Ev+0xb3)[0x10e2b33]
./mysqld(_Z21os_thread_create_funcPFPvS_ES_Pm+0x277)[0xff3d37]
./mysqld(_Z34innobase_start_or_create_for_mysqlv+0x1686)[0x1097196]
./mysqld[0xf7669d]
./mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x7caac1]
./mysqld[0xd35576]
./mysqld(_Z11plugin_initPiPPci+0x965)[0xd3a3c5]
./mysqld[0x77641b]
./mysqld(_Z11mysqld_mainiPPc+0x516)[0x779316]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f7a891f3af5]
./mysqld[0x76fdc9]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
四、配置文件
[root@localhost mysql-5.7.11]# cd support-files/
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite '/etc/my.cnf'? yes
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost support-files]# vim /etc/init.d/mysql
#!/bin/sh
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
# MySQL daemon start/stop script.
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.
# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO
# If you install MySQL on some other places than /usr/local/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
# [mysqld]
# basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
# and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
# below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/home/mysql/
datadir=/home/mysql/data
# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900
# Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql"
# The following variables are only set for letting mysql.server find things.
五、配置環境變量
vi .bash_profile
# User specific environment and startup programs export MYSQL_HOME="/home/mysql/mysql-5.7.9" export PATH="$PATH:$MYSQL_HOME/bin"
六、添加開機啟動服務
七、啟動mysql
[root@localhost ~]# su - mysql
[mysql@localhost ~]$ service mysql start
Starting MySQL ERROR! Couldn't find MySQL server (/home/mysql//bin/mysqld_safe)
(果然出錯了)~~~~~
basedir=/usr/sever/mysql-5.7.11/
datadir=/home/mysql/data
然后修改到末尾出現:
E45: 'readonly' option is set (add ! to override)
按照網上的解決方案:ESC后輸入:wq!,(參考鏈接)
強制保存后,顯示的錯誤
"/etc/rc.d/init.d/mysql"
"/etc/rc.d/init.d/mysql" E212: Can't open file for writing
Enter后,繼續ESC :x顯示
E505: "/etc/rc.d/init.d/mysql" is read-only (add ! to override)
(如果仍舊不能保存退出的話,就重啟開啟以個連接修改試試,可能會出現 --bash-4.2問題),上變得不能夠編輯的問題可能是由於我在[mysql@localhost ~]路徑下修改文件原因。
參考鏈接:linux下安裝mysql.tar.gz
---------------------
4/4/16 測試安裝,然后后邊幾天一直在斷斷續續解決 tar.gz七 中的問題
注意學習和解決問題的效率
4/6/16 問題解決過程中發現沒有/home/mysql/data/下根本就沒有pid文件,重新安裝rpm版本,補充