2012-07-18 506 views
2

我剛剛下載的MySQL 5.0.9源代碼,並建立和安裝爲root用戶:MYSQL無法啓動服務

./configure 
./make 
./make install 

現在我試圖彈出的mysqld但錯誤說:

[root libexec]# ./mysqld 
120718 7:37:09 [ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists! 

120718 7:37:09 [ERROR] Aborting 

120718 7:37:09 [Note] ./mysqld: Shutdown complete 

[root libexec]# 

請注意,我以root用戶身份執行了所有操作,並且正嘗試首次啓動服務?

我做了什麼user868766陳述如下,但無法成功執行最後的命令。但是現在我試圖直接調用它時會得到其他的東西:

順便說一句,我們如何設置MySQL根密碼?

[root libexec]# ./mysqld 
InnoDB: The first specified data file ./ibdata1 did not exist: 
InnoDB: a new database to be created! 
120718 7:52:35 InnoDB: Setting file ./ibdata1 size to 10 MB 
InnoDB: Database physically writes the file full: wait... 
120718 7:52:35 InnoDB: Log file ./ib_logfile0 did not exist: new to be created 
InnoDB: Setting log file ./ib_logfile0 size to 5 MB 
InnoDB: Database physically writes the file full: wait... 
120718 7:52:35 InnoDB: Log file ./ib_logfile1 did not exist: new to be created 
InnoDB: Setting log file ./ib_logfile1 size to 5 MB 
InnoDB: Database physically writes the file full: wait... 
InnoDB: Doublewrite buffer not found: creating new 
InnoDB: Doublewrite buffer created 
InnoDB: Creating foreign key constraint system tables 
InnoDB: Foreign key constraint system tables created 
120718 7:52:35 InnoDB: Started; log sequence number 0 0 
120718 7:52:35 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 

我只是跑按照目前由user868766提供的鏈接信息:

[root bin]# mysql_install_db 

注意事項使用比其他命令是給問題:

[root bin]# mysql_install_db -user=mysql -ldata=/opt/mysql/mysql/data 
Installing MySQL system tables... 
120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line 

120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line 

/usr/local/libexec/mysqld: File 'data=/opt/mysql/mysql/data' not found (Errcode: 2) 
120718 8:35:00 [ERROR] Could not use data=/opt/mysql/mysql/data for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it. 
OK 
Filling help tables... 
120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line 

120718 8:35:00 [Warning] Ignoring user change to 'ser=mysql' because the user was set to 'mysql' earlier on the command line 

/usr/local/libexec/mysqld: File 'data=/opt/mysql/mysql/data' not found (Errcode: 2) 
120718 8:35:00 [ERROR] Could not use data=/opt/mysql/mysql/data for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it. 
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/local/bin/mysqladmin -u root password 'new-password' 
/usr/local/bin/mysqladmin -u root -h idc-bldtool01 password 'new-password' 

Alternatively you can run: 
/usr/local/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/local ; /usr/local/bin/mysqld_safe & 

You can test the MySQL daemon with mysql-test-run.pl 
cd mysql-test ; perl mysql-test-run.pl 

Please report any problems with the /usr/local/bin/mysqlbug script! 

The latest information about MySQL is available on the web at 
http://www.mysql.com 
Support MySQL by buying support/licenses at http://shop.mysql.com 
[root bin]# ls -l /opt/mysql/mysql/data 
total 0 

在此之後然而我能夠帶上mysqld:

[root libexec]# ./mysqld 
InnoDB: Log scan progressed past the checkpoint lsn 0 36808 
120718 8:37:22 InnoDB: Database was not shut down normally! 
InnoDB: Starting crash recovery. 
InnoDB: Reading tablespace information from the .ibd files... 
InnoDB: Restoring possible half-written data pages from the doublewrite 
InnoDB: buffer... 
InnoDB: Doing recovery: scanned up to log sequence number 0 43655 
120718 8:37:22 InnoDB: Starting an apply batch of log records to the database... 
InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed 
120718 8:37:23 InnoDB: Started; log sequence number 0 43655 
120718 8:37:23 [Note] ./mysqld: ready for connections. 
Version: '5.0.91' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution 

現在我想設置root的密碼作爲腹地在上述控制檯轉儲:

[root~]# /usr/local/bin/mysql_secure_installation 




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL 
     SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 


In order to log into MySQL to secure it, we'll need the current 
password for the root user. If you've just installed MySQL, and 
you haven't set the root password yet, the password will be blank, 
so you should just press enter here. 

Enter current password for root (enter for none): 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 
Enter current password for root (enter for none): 
Aborting! 

Cleaning up... 

請讓我知道我該怎麼解決這個問題?

感謝user868766我設法解決並能夠調出mysql並連接到它。

回答

4

請試試這個:

1. cd /var/lib/mysql 

2. adduser mysql 

3. chown mysql:mysql -R /var/lib/mysql 

4. service mysqld restart 

請執行在給定的順序命令它應該幫助你。

+0

我所做的一切,但,最後命令給出問題:MySQL的root]#/ sbin目錄/服務啓動MySQL 啓動:無法識別的服務 – Prakash 2012-07-18 14:50:36

+0

請嘗試這種服務mysqld的重新啓動 – 2012-07-18 15:09:39

+0

是我安裝正確導致其無法找到mysqld服務只是已安裝:[root libexec]#/ sbin/service mysqld restart mysqld:無法識別的服務 – Prakash 2012-07-18 15:12:44