解壓縮MySQL [html] [root@localhost test]# tar -xvf MySQL-5.6.12-2.linux_glibc2.5.i386.rpm-bundle.tar MySQL-test-5.6.12-2.linux_glibc2.5.i386.rpm My" />
MySQL安裝過程中出現的問題
1>解壓縮MySQL
[html] [root@localhost test]# tar -xvf MySQL-5.6.12-2.linux_glibc2.5.i386.rpm-bundle.tar MySQL-test-5.6.12-2.linux_glibc2.5.i386.rpm MySQL-shared-5.6.12-2.linux_glibc2.5.i386.rpm MySQL-embedded-5.6.12-2.linux_glibc2.5.i386.rpm MySQL-client-5.6.12-2.linux_glibc2.5.i386.rpm MySQL-devel-5.6.12-2.linux_glibc2.5.i386.rpm MySQL-server-5.6.12-2.linux_glibc2.5.i386.rpm MySQL-shared-compat-5.6.12-2.linux_glibc2.5.i386.rpm
2>安裝MySQL
[html]
(1) 如果已經安裝了MySQL,會出現以下提示信息:
[root@localhost test]# rpm -ivh MySQL-server-5.6.12-2.linux_glibc2.5.i386.rpm Preparing... ########################################### [100%] package MySQL-server-5.6.12-2.linux_glibc2.5.i386 is already installed [root@localhost test]# rpm -ivh MySQL-client-5.6.12-2.linux_glibc2.5.i386.rpm Preparing... ########################################### [100%] package MySQL-client-5.6.12-2.linux_glibc2.5.i386 is already installed
可以先進行卸載MySQL
使用命令rpm –e MySQL-server-5.6.12-2.linux_glibc2.5.i386.rpm –nodeps
[html] rpm –e MySQL-server-5.6.12-2.linux_glibc2.5.i386.rpm --nodeps
(2)如果沒有提示這些信息,那么會正常安裝.
[html] [root@localhost test]# rpm -ivh MySQL-server-5.6.12-2.linux_glibc2.5.i386.rpm Preparing... ########################################### [100%] 1:MySQL-server ########################################### [100%] [root@localhost test]# rpm -ivh MySQL-client-5.6.12-2.linux_glibc2.5.i386.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%]
3>啟動MySQL
(1)首次啟動MySQL服務器,出現異常信息的解決辦法
[html] [root@localhost test]# service mysql start Starting MySQL.......................... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.pid).
由于mysql啟動的僵死進程,需要將其殺死之后方能啟動
[html] [root@localhost test]# ps -ef | grep mysql root 1953 1 0 22:18 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid mysql 2171 1953 0 22:18 ? 00:00:04 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid root 3282 1 0 22:37 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.pid mysql 3386 3282 2 22:37 pts/0 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.err --pid-file=/var/lib/mysql/localhost.pid root 3482 2681 0 22:38 pts/0 00:00:00 grep mysql
使用kill -9 2171之類殺死
再使用service mysql start或者/etc/init.d/mysql start
[html] [root@localhost test]# service mysql start Starting MySQL SUCCESS!
4>登錄MySQL
[html] [root@localhost test]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 2 Server version: 5.6.12 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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_secret中
[html] cat .mysql_secret 進入mysql之后需要設置密碼,否則不能進行任何操作,如果提示ERROR 1862 (HY000): Your password has expired. To log in you mustchange it using a client that supports expired passwords. /
那么也需要重新設置密碼
MySQL文檔中詞條MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS有下面的信息
查找SET PASSWORD
為root用戶設置新密碼
[html] set password for ‘root’@’localhost’=password(‘root’)
之后可以進行正常的操作
忘記mysql root密碼的解決方法
一. MySQL密碼的恢復方法之一
如果忘記了MySQL的root密碼,可以用以下方法重新設置:
1. KILL掉系統里的MySQL進程;[html] killall -TERM mysqld 2. 用以下命令啟動MySQL,以不檢查權限的方式啟動;[html] safe_mysqld --skip-grant-tables & 3. 然后用空密碼方式使用root用戶登錄 MySQL;[html] mysql -u root 4. 修改root用戶的密碼;[html] mysql> update mysql.user set password=PASSWORD('新密碼') where User='root'; mysql> flush privileges; mysql> quit
重新啟動MySQL,就可以使用新密碼登錄了。
二. MySQL密碼的恢復方法二
有可能你的系統沒有 safe_mysqld 程序(比如我現在用的 ubuntu操作系統, apt-get安裝的mysql) , 下面方法可以恢復
1. 停止mysqld;
[html] /etc/init.d/mysql stop
(您可能有其它的方法,總之停止mysqld的運行就可以了)
2. 用以下命令啟動MySQL,以不檢查權限的方式啟動;
[html] mysqld --skip-grant-tables &
3. 然后用空密碼方式使用root用戶登錄 MySQL;
mysql -u root
4. 修改root用戶的密碼;
[html] mysql> update mysql.user set password=PASSWORD('newpassword') where User='root'; mysql> flush privileges; mysql> quit
重新啟動MySQL
[html] /etc/init.d/mysql restart
就可以使用新密碼 newpassword 登錄了
mysql The server quit without updating PID file異常解決辦法
安裝好mysql后,用
Java代碼
/usr/local/mysql/bin/mysqld_safe &
去啟動mysql,總是處于僵死狀態,后來去suport_files 用mysql.server start 來啟動,
提示mysql The server quit without updating PID file。在網上找了下,原來說是有mysql
啟動的僵死進程。
用ps -ef |grep mysql 發現有
Php代碼 root 4507 1 0 21:40 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql mysql 4793 4507 0 21:40 ? 00:00:03 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql.......
于是kill 4793,再啟動。就正常了
ps:kill root下的進程4507是沒
Mysql報錯的解決'Can't connect to local MySQL server through socket '/tmp/mysql.sock'
[root@localhost mysql]# mysqlERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)[root@localhost mysql]# service mysqld restart 這里說明mysqld并沒有啟動,MySQL manager or server PID file could not be found! [FAILED]Starting MySQL/etc/init.d/mysqld: line 159: kill: (18977) - No such process [FAILED][root@localhost mysql]# cd bin[root@localhost bin]# ./mysqlERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) 這里就說了不能通過/tmp/mysql.sock連接數據庫。[root@localhost bin]# cd /tmp 進去檢查,看到有這個文件,所以看別的原因。[root@localhost tmp]# lsgconfd-root mapping-root mysql.sock mysql-test-ports mysql-test-ports.sem scim-panel-socket:0-root VMwareDnD vmware-root vmware.txt[root@localhost tmp]# cd /usr/local/mysql/[root@localhost mysql]# pwd/usr/local/mysql[root@localhost mysql]# chown -R root:mysql . 忽然想起來了沒有設置權限呢,開始設置權限[root@localhost mysql]# lltotal 36drwxr-xr-x 2 root mysql 4096 Nov 28 21:51 bindrwxr-xr-x 3 root mysql 4096 Nov 28 21:50 includedrwxr-xr-x 2 root mysql 4096 Nov 28 21:50 infodrwxr-xr-x 3 root mysql 4096 Nov 28 21:50 libdrwxr-xr-x 2 root mysql 4096 Nov 28 21:51 libexecdrwxr-xr-x 4 root mysql 4096 Nov 28 21:50 mandrwxr-xr-x 8 root mysql 4096 Nov 28 21:51 mysql-testdrwxr-xr-x 3 root mysql 4096 Nov 28 21:50 sharedrwxr-xr-x 5 root mysql 4096 Nov 28 21:50 sql-bench[root@localhost mysql]# chown -R mysql /var/lib/mysql[root@localhost mysql]# cp share/mysql/my-huge.cnf /etc/my.cnf[root@localhost mysql]# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld[root@localhost mysql]# chmod 755 /etc/rc.d/init.d/mysqld[root@localhost mysql]# chkconfig --add mysqld[root@localhost mysql]# chkconfig --level 345 mysqld on=======error========[root@localhost mysql]# mysqladmin -u root password 'uplooking'mysqladmin: connect to server at 'localhost' failederror: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)'Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists! 又是上邊一樣的錯誤[root@localhost mysql]# bin/mysql startERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)[root@localhost mysql]# /etc/rc.d/init.d/mysqld statusMySQL is not running, but lock exists [FAILED] 這里說的是沒有運行著mysql,但是還在鎖定。這時候我看到了下邊那篇文章,重新檢查了一遍權限,[root@localhost mysql]# chown -R mysql:mysql /var/lib/mysql 在這里,我原來設置的時候這個組沒有設置,只寫了chown -R mysql /var/lib/mysql,分組被我忽略掉了,哎,折騰這么長時間。[root@localhost mysql]# /etc/rc.d/init.d/mysqld start 從這里,mysql啟動正常了Starting MySQL [ OK ][root@localhost mysql]# /etc/rc.d/init.d/mysqld stopShutting down MySQL [ OK ][root@localhost mysql]#[root@localhost mysql]# mysqladmin -u root password 'uplooking' 這里是說服務器沒有啟動mysqladmin: connect to server at 'localhost' failederror: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists![root@localhost mysql]# /etc/rc.d/init.d/mysqld start 啟動服務器Starting MySQL [ OK ][root@localhost mysql]# mysqladmin -u root password 'uplooking' 添加root密碼[root@localhost mysql]# mysqlERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)[root@localhost mysql]# mysql -u root -p 用root密碼登陸,測試。Enter password:Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 3Server version: 5.0.56-Comsenz-log SourceType 'help;' or '/h' for help. Type '/c' to clear the buffer.mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || test |+--------------------+3 rows in set (0.00 sec)mysql> quitBye[root@localhost mysql]# service mysqld restartShutting down MySQL [ OK ]Starting MySQL [ OK ][root@localhost mysql]#====權限的驗證測試====[root@localhost mysql]# cd /tmp[root@localhost tmp]# mkdir test[root@localhost tmp]# cd test[root@localhost test]# ls[root@localhost test]# touch 11[root@localhost test]# lltotal 0-rw-r--r-- 1 root root 0 Nov 28 22:37 11[root@localhost test]# chown -R mysql 11[root@localhost test]# lltotal 0-rw-r--r-- 1 mysql root 0 Nov 28 22:37 11[root@localhost test]#=========================
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com