搜尋
首頁資料庫mysql教程MySQL安装过程中出现的问题_MySQL

bitsCN.com

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]#=========================

 

 

bitsCN.com
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
將用戶添加到MySQL:完整的教程將用戶添加到MySQL:完整的教程May 12, 2025 am 12:14 AM

掌握添加MySQL用戶的方法對於數據庫管理員和開發者至關重要,因為它確保數據庫的安全性和訪問控制。 1)使用CREATEUSER命令創建新用戶,2)通過GRANT命令分配權限,3)使用FLUSHPRIVILEGES確保權限生效,4)定期審計和清理用戶賬戶以維護性能和安全。

掌握mySQL字符串數據類型:varchar vs.文本與char掌握mySQL字符串數據類型:varchar vs.文本與charMay 12, 2025 am 12:12 AM

chosecharforfixed-lengthdata,varcharforvariable-lengthdata,andtextforlargetextfield.1)chariseffity forconsistent-lengthdatalikecodes.2)varcharsuitsvariable-lengthdatalikenames,ballancingflexibilitibility andperformance.3)

MySQL:字符串數據類型和索引:最佳實踐MySQL:字符串數據類型和索引:最佳實踐May 12, 2025 am 12:11 AM

在MySQL中處理字符串數據類型和索引的最佳實踐包括:1)選擇合適的字符串類型,如CHAR用於固定長度,VARCHAR用於可變長度,TEXT用於大文本;2)謹慎索引,避免過度索引,針對常用查詢創建索引;3)使用前綴索引和全文索引優化長字符串搜索;4)定期監控和優化索引,保持索引小巧高效。通過這些方法,可以在讀取和寫入性能之間取得平衡,提升數據庫效率。

mysql:如何遠程添加用戶mysql:如何遠程添加用戶May 12, 2025 am 12:10 AM

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

MySQL字符串數據類型的最終指南:有效的數據存儲MySQL字符串數據類型的最終指南:有效的數據存儲May 12, 2025 am 12:05 AM

tostorestringsefliceflicyInmySql,ChooSetherightDataTypeBasedyOrneOrneEds:1)USEcharforFixed-LengthStstringStringStringSlikeCountryCodes.2)UseVarcharforvariable-lengtthslikenames.3)USETEXTCONTENT.3)

mysql blob vs.文本:為大對象選擇正確的數據類型mysql blob vs.文本:為大對象選擇正確的數據類型May 11, 2025 am 12:13 AM

選擇MySQL的BLOB和TEXT數據類型時,BLOB適合存儲二進制數據,TEXT適合存儲文本數據。 1)BLOB適用於圖片、音頻等二進制數據,2)TEXT適用於文章、評論等文本數據,選擇時需考慮數據性質和性能優化。

MySQL:我應該將root用戶用於產品嗎?MySQL:我應該將root用戶用於產品嗎?May 11, 2025 am 12:11 AM

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQL字符串數據類型說明了:選擇適合您數據的合適類型MySQL字符串數據類型說明了:選擇適合您數據的合適類型May 11, 2025 am 12:10 AM

mySqlStringDatatAtatPessHouldBechoseBasedondatActarActeristicsAndusecases:1)USEcharforFixed lengthStstringStringStringSlikeCountryCodes.2)usevarcharforvariable-lengtthslikeLikenames.3)usebarnionororvarinyorvarinyorvarybinarydatalgebenedaTalgeextocrabextrapon.4)

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能