修改mysql root密码

1. 首先停止正在运行的MySQL进程
Linux下,运行 killall -TERM mysqld
Windows下,如果写成服务的 可以运行:net stop mysql,如未加载为服务,可直接在进程管理器中进行关闭。

2. 启动MySQL
Linux下,运行 mysqld --skip-grant-tables --user=root &
Windows下,在命令行下运行 X:/MySQL/bin/mysqld-nt.exe --skip-grant-tables

3. 完成以后就可以不用密码进入MySQL了
Linux下,运行 mysql -u root 进入
Windows下,运行 X:/MySQL/bin/mysql -u root 进入

4. 更改密码
>use mysql; 
>update user set password=password('新密码') where user='root'; 
>flush privileges; 

5. 用新密码登录

Linux下,运行 mysql -u root -p

输入密码

------------------------------------------------------------------------------------------

fedora install mysql: $sudo yum -y install mysql-server

start mysql:   $ sudo service mysqld start

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 yfzhu.host 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

-----------------------------------------------------------------------

A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:

To start mysql server:

/etc/init.d/mysqld start

* To stop mysql server:

/etc/init.d/mysqld stop

* To restart mysql server

 /etc/init.d/mysqld restart

Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:

# service mysqld start
# service mysqld stop
# service mysqld restart

(B) If you are using mysql on Debian / Ubuntu Linux then use following command:

* To start mysql server:

/etc/init.d/mysql start

* To stop mysql server:

/etc/init.d/mysql stop

* To restart mysql server

/etc/init.d/mysql restart

猜你喜欢

转载自yefzhu.iteye.com/blog/1688244