ubuntu建站遇到的mysql数据库问题
生活随笔
收集整理的這篇文章主要介紹了
ubuntu建站遇到的mysql数据库问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
? ? ? ? ? ?將源站所有代碼和數據拷入/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也報該錯誤。解決辦法如下:
root@bt:~# cd /usr/bin root@bt :/usr/bin# /usr/bin/mysql_install_db Installing MySQL system tables... OK Filling help tables... OKTo start mysqld at boot time you have to copy support-files/mysql.server to the right place for your systemPLEASE 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_installationwhich 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.plPlease 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/mysqlroot@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]節提供的用戶名和密碼。具體命令如下:
?
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: 0mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec)mysql> quit Bye上面命令執行完成后,就可以以root用戶(密碼:root)登錄,當然密碼可以在上面的命令中設成其他的值。登錄結果如下:
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)轉載于:https://my.oschina.net/duhaizhang/blog/66353
總結
以上是生活随笔為你收集整理的ubuntu建站遇到的mysql数据库问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#打印控件的使用实例
- 下一篇: 让软件版本信息自动引用SVN修订版本号