Reprint please the head source link and the tail two-dimensional code together reprint, this article from countercurrent fish yuiop:http://blog.csdn.net/hejjunlin/article/details/52768613
Preface: The data of the database is increasing every day, the overall risk of automatic deletion mechanism is too big, want to keep more historical data for query, so it is imperative to change from small hbase to large hbase. The Data Warehouse migration is recorded today. Look at the agenda:
- Completely uninstall MySQL
- Install MySQL
- MySQL database initialization and related configuration
- Storing Data Catalog Modifications
- Client connection problem (intermediate process)
- Small summary
Completely uninstall MySQL
Yum-style installation of MySQL
yum remove mysql mysql-server mysql-libs compat-mysql51-rf /var/lib/mysqlrm /etc/my.cnf
See if you have MySQL Related:
rpm -qa|grep mysql
RPM-style installation of MySQL
- Check if MySQL is installed in RPM package on the system:
[[email protected]-h5-web-online001-sjhl ~]# rpm -qa | grep -i mysqlMySQL-server-5.6.17-1.el6.i686MySQL-client-5.6.17-1.el6.i686
[[email protected]-h5-web-online001-sjhl ~]# rpm -e MySQL-server-5.6.17-1.el6.i686[[email protected]-h5-web-online001-sjhl ~]# rpm -e MySQL-client-5.6.17-1.el6.i686
[[email protected]-h5-web-online001-sjhl ~]# chkconfig --list | grep -i mysql[[email protected]-h5-web-online001-sjhl ~]# chkconfig --del mysql
- Delete a distributed MySQL folder
[[email protected]-h5-web-online001-sjhl ~]# whereis mysql 或者 find / -name mysqlmysql: /usr/lib/mysql /usr/share/mysql
Empty all directories and files related to MySQL
-rf-rf-rf /usr/my.cnf
With these steps, MySQL should have been completely uninstalled.
Install MySQL
Installation of MySQL via Yum
I am using yum to perform MySQL database installation, first we can enter Yum List | grep mysql command to view the downloadable version of the MySQL database available on Yum:
[[email protected]-h5-web-online001-sjhl ~]# yum list | grep mysql
You can get the downloadable version of the MySQL database on the Yum server:
Then we can enter
-y mysql-server mysql mysql-devel
command to install MySQL mysql-server mysql-devel (Note: We did not install MySQL client when we installed MySQL database, we also need to install the Mysql-server server)
[[email protected]-h5-web-online001-sjhl ~]# yum install -y mysql-server mysql mysql-deve
After waiting for some time, Yum will help us choose the software needed to install the MySQL database and some other ancillary software.
We found that installing the MySQL database through the Yum method saved a lot of unnecessary hassle, and when the following results were present, the MySQL database was installed almost successfully.
At this point we can view the version of the mysql-server that we just installed with the following command
[[email protected]-h5-web-online001-sjhl ~]# rpm -qi mysql-server
We installed the Mysql-server is not the latest version, if you want to try the latest version, then go to the MySQL official website to download RPM package installation (but it is not recommended to install the latest, there may be a variety of unknown problems), so that our MySQL database has been installed.
MySQL database initialization and related configuration
After we install the MySQL database, we will find a mysqld service, this database service, we can start our MySQL service by entering the service mysqld Start command.
Note: If we are starting the MySQL service for the first time, the MySQL server will first initialize the configuration, such as:
[[email protected]-h5-web-online001-sjhl ~]# service mysqld start
However the question came: starting mysqld: [Failed]
And then read the next log to say: Does you already has another MYSQLD server running on port:3306?
is to say is not have mysqld occupy 3306 port, obviously has unloaded.
Then look at the status of the lower port:
Check the port number of MySQL
[[email protected]-h5-web-online001-sjhl ~]# netstat -a -t -n|grep 3306[[email protected]-h5-web-online001-sjhl ~]# netstat -nltp|grep mysql
To stop the service:
[[email protected]-h5-web-online001-sjhl ~]# service mysqld stop
Then check to see if there is a mysqld process
[[email protected]-h5-web-online001-sjhl ~]# ps -ef|grep mysqld
Sure enough in the 3306 port, only kill this, re-start, it should be no problem.
Finally with the command:
[[email protected]-h5-web-online001-sjhl ~]# /etc/inint.d/mysqld start
To start the MySQL service, this is normal.
MySQL database after the installation will only have a root administrator account, but at this time the root account has not set a password for it, the first time when the MySQL service started, some initialization of the database, in the output of a large string of information, we see a line of information:/usr/ bin/mysqladmin-u root password ' new-password '//Set password for root account
So we can use this command to set the password for our root account (Note: This root account is the root account of MySQL, not the root account of Linux)
[[email protected]-h5-web-online001-sjhl ~]# mysqladmin -u root password ‘123456‘
At this point we can log in to our MySQL database via the mysql-u root-p command.
Storing Data Catalog Modifications
Because the default MySQL installed partition disk space is very small, you need to modify the corresponding storage data file path, find/etc/mycnf, with vim open, corresponding modification, DataDir is to modify the target, socket this want a quick change, found that after the change, can not login MySQL, There should be another configuration file has not changed, so temporarily gave up.
With the command
/etc/init.d/mysqld restart
To restart the MySQL service can be effective (PS: Make sure to first stop the MySQL service, and then modify the above file)
Client connectivity is another problem.
When thought that the above is the work of the time, with the MySQL visual tools to connect, found that the following error:
The reason is that the remote client port is not authorized, and then authorization is started:
Here are some options:
- For example, if you want to myuser use MyPassword to connect to a MySQL server from any host.
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;FLUSH PRIVILEGES;
- If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.6 and use MyPassword as the password
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.6‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;FLUSH PRIVILEGES;
- If you want to allow users to connect to the MySQL server's DK database myuser from the IP-192.168.1.6 host, and use MyPassword as the password
GRANT ALL PRIVILEGES ON dk.* TO ‘myuser‘@‘192.168.1.6‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;FLUSH PRIVILEGES;
This is the next!!!!
Small summary
Finally, three articles are summarized:
- Install the environment on the target machine first. such as MySQL
- Data is configured, and the test can be accessed by
- Data migration, the original machine on the package copy to the new machine.
Attach some commonly used MySQL to start, stop, restart common commands:
Start
1. Start with service:
start (5.0版本是mysqld)service mysql start (5.5.7版本是mysql)
2. Start with mysqld script:
start
3. Start with Safe_mysqld:
safe_mysqld&
Stop
1. Start with service:
stop
2. Start with mysqld script:
stop
Restart
1. Start with service:
service mysqld restart service mysql restart (5.5.7版本命令)
2. Start with mysqld script:
/etc/init.d/mysqld restart
The first time to get blog update reminders, as well as more Android dry, source code Analysis , Welcome to follow my public number, sweep the bottom QR code or long press to identify two-dimensional code, you can pay attention to.
If you feel good, easy to praise, but also to the author's affirmation, can also share this public number to you more people, original not easy
Linux Next Data Warehouse for Migration records