將源站全部代碼和數據拷入/var/www目錄下,經過瀏覽器訪問127.0.0.1訪問時看不到正常頁面,報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)。能夠看出mysql出錯了,在終端控制器下登陸mysql也報該錯誤。解決辦法以下:html
root@bt:~# cd /usr/bin root@bt :/usr/bin# /usr/bin/mysql_install_db Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h bt password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/scripts/mysqlbug script! The latest information about MySQL is available at http://www.mysql.com/ Support MySQL by buying support/licenses from http://shop.mysql.com/
root@bt :/usr/bin# cd /usr root@bt :/usr# /usr/bin/mysqld_safe & [1] 2639 root@bt :/usr# 120710 07:40:51 mysqld_safe Logging to syslog. 120710 07:40:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql root@bt :/usr# /usr/bin/mysqladmin -u root password 'root' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
如上,一步步輸入命令,從上面能夠看到輸完命令最後嘗試登陸時,又報另外一個錯誤:error: 'Access denied for user 'root'@'localhost' (using password: NO)'。解決辦法(參考網址:http://www.jb51.net/LINUXjishu/10981.html)以下:直接使用/etc/mysql/debian.cnf文件中[client]節提供的用戶名和密碼。具體命令以下:mysql
root@bt :/# vi /etc/mysql/debian.cnf root@bt :/# mysql -udebian-sys-maint -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.41-3ubuntu12.10 (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> UPDATE mysql.user SET Password=PASSWORD('root') where USER='root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
上面命令執行完成後,就能夠以root用戶(密碼:root)登陸,固然密碼能夠在上面的命令中設成其餘的值。登陸結果以下:sql
root@bt :/# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.1.41-3ubuntu12.10 (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show datebases; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'datebases' at line 1 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | +--------------------+ 2 rows in set (0.00 sec)