将源站全部代码和数据拷入/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)