Under liunx install mysql online

One: Online install mysql

1, first detected what it has not been installed before mysql

  Command: rpm -qa | grep mysql

2, delete the mysql command: rpm -e --nodeps `rpm -qa | grep mysql`

3, line installation mysql command: yum -y install mysql-server

4, open the mysql service: service mysqld start restart service: service mysqld restart

5, the mysql service is loaded into the boot entry: chkconfig mysqld on

6, initial configuration mysql service
whereis mysql_secure_installation
executes the script / usr / bin / mysql_secure_installation

7, access mysql service
mysql -h master.hive.crxy.cn -uroot -proot
question: Host '192.168.1.102' is not allowed to connect to this MySQL server
solutions:
. Mysql> Grant * to * All privileges ON ' root '@'% 'identified by ' root '; ( this means: all rights conferred on all databases and tables to all the root user on any host)
MySQL> the flush privileges;

Two: Change Password:
First, the original myql with root password;
method:
outside mysql systems, use mysqladmin
# mysqladmin -u root -p password "test123"
the Enter password: [Enter the old password]

Method two:
by logging system mysql,
# -uroot-mysql -p
the Enter password:] [enter the original password
mysql> use mysql;
mysql> Update User password SET PASSWORD = ( "Test") WHERE User = 'the root';
mysql> privileges the flush;
MySQL> Exit;

Second, forget the root of the original myql password;

First, you must have root access to the operating system. Even if the system root privileges are not, first consider the root system longer follow the steps below.
Similar to safe mode login system, it was suggested that a pkill mysql, but I do not recommend Ha. Because when you execute this command, will lead to such a situation:
/etc/init.d/mysqld Status
mysqld Dead But subsys Locked
so even if you are starting mysql in safe mode may not be useful, it is generally like this / etc / init.d / mysqld stop, if you are unfortunate enough to use the pkill, then start it again stop slightly.
The mysqld_safe --skip-Grant-# & Tables
&, showing in the background, the background is no longer running, a terminal would then open slightly.
Mysql #
mysql> use mysql;
mysql> the UPDATE the SET password = User password ( "test123") the WHERE User = 'the root';
mysql> the flush privileges;
mysql> Exit;
## originally mysql is not case sensitive, but this is the specific value of the modified mysql mysql database, to be noticed.

Online Installation Method Two: mysql version 5.6

# 1, delete the mysql service is installed in order to install a new rpm package

rpm -qa |grep mysql |xargs -n 1 rpm -e --nodeps

whereis mysql |xargs -n 1 rm -rf
whereis mysqld |xargs -n 1 rm -rf

rm -rf /var/lib/mysql


yum -y install wget

wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

rpm -ivh mysql-community-release-el6-5.noarch.rpm

yum list |grep mysql

yum -y install mysql-server mysql mysql-devel


# 2, start the service,
change the root password

service mysqld start

service mysqld status

mysqladmin -u root password 123456

Guess you like

Origin www.cnblogs.com/YuJianhui/p/12091781.html