lnmp1.1 转移mysql数据库的问题 MySQL: Starting MySQL….. ERROR! The server quit without updating PID file
1、安装前修改/etc/my.cnf,加入datadir = /data/mysql/ 再执行sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf 之后的命令,将里面的给目录加权限修改为你新的目录
2、安装后
停止mysql,移动/usr/local/mysql/var/ 到新目录,修改/etc/my.cnf ,查找[mysqld] ,在下面加入datadir = /data/mysql/ ,给新目录加权限,重启。
注意,修改前先备份数据!!!!
我是安装后修改/etc/my.cnf 出现 MySQL: Starting MySQL….. ERROR! The server quit without updating PID file
按下面方法,等于重新安装了mysql,数据都没了。
1 问题
[root@localhost mysql]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
[root@localhost mysql]# /etc/rc.d/init.d/mysql start
Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid). [FAILED]
2 原因
没有初始化权限表
3 解决办法
#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db
4 本人解决过程
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$ scripts/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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./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 . ; ./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 ./bin/mysqlbug script!
[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running (11830) [ OK ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
Starting MySQL [ OK ]
上面成功后,改数据库密码
Linux下修改Mysql的用户(root)的密码
修改的用户都以root为列。
一、拥有原来的myql的root的密码;
方法一:
在mysql系统外,使用mysqladmin
# mysqladmin -u root -p password "test123"
Enter password: 【输入原来的密码】
方法二:
通过登录mysql系统,
# mysql -uroot -p
Enter password: 【输入原来的密码】
mysql>use mysql;
mysql> update user set password=passworD("test") where user='root';
mysql> flush privileges;
mysql> exit;
二、忘记原来的myql的root的密码;
首先,你必须要有操作系统的root权限了。要是连系统的root权限都没有的话,先考虑root系统再走下面的步骤。
类似于安全模式登录系统,有人建议说是pkill mysql,但是我不建议哈。因为当你执行了这个命令后,会导致这样的状况:
/etc/init.d/mysqld status
mysqld dead but subsys locked
这样即使你是在安全模式下启动mysql都未必会有用的,所以一般是这样/etc/init.d/mysqld stop,如果你不幸先用了pkill,那么就start一下再stop咯。
# mysqld_safe --skip-grant-tables &
&,表示在后台运行,不再后台运行的话,就再打开一个终端咯。
# mysql
mysql> use mysql;
mysql> UPDATE user SET password=password("test123") WHERE user='root';
mysql> flush privileges;
mysql> exit;
##本来mysql是不分大小写的,但是这个是修改的mysql中的mysql数据库的具体的值,要注意到。