1, the installation of MySQL
I installed it directly using Apt-get: sudo apt-get install Mysql-server
sudo apt-get install mysql-client
2. Configure MySQL Administrator password
sudo mysqladmin-u root current password new password
I didn't seem to have any trouble installing it.
3. Check the status of MySQL
sudo netstat-tap | grep MySQL
4. Start/stop/restart MySQL
Sudo/etc/init.d/mysql start
Sudo/etc/init.d/mysql stop
Sudo/etc/init.d/mysql restart
Some versions will prompt you to use Sudo/etc/init.d/start MySQL after operation
5. Log in to MySQL server
Mysql-u root-p
Prompt for password (enter PASSWORD:)
6. telnet to MySQL
MySQL host name-u root-p
7. Exit MySQL Server
Mysql> CTRL C
8. View version Information
Mysql>s is \s
9. View Help
Mysql>help
10. View the MySQL version and the current date of the server
All Plus "\"
Mysql>select version (). current_date
11, if you encounter file permissions issues, such as: The permissions are root and your user name is Zhangsan, you can use the following code to change permissions:
sudo chown username target
sudo chgrp username target
If it is a folder and the files inside are also controlled by permission, sudo chown/chgrp-r username target can be used.
Of course you can use: sudo chmod u+x target to change read-only to read-write
Note: username (zhangsan) target (relative path to the target file or folder)
12, now has installed the MySQL client and MySQL server (if the installation process is still problematic, you can search the plans of the gods, strongly recommend our powerful www.iteye.com)
Data migration is now in progress.
Because this time I migrated the database on the remote server to local and used it as an internal test development, so I chose to use the Mysqldump tool.
13, connect, log on to the remote server
SSH server name @ specific IP address (ex:202.108.22.5)
ENTER password:xxxxxxx
Then enter: sudo mysql-u root-p
Then re-enter the remote database login password, as the above root may also be other username
14. Operation Remote Service side
Mysql>show databases;
Mysql>use specific database name;
Mysql>show tables;
Mysql>desc specific table name;
Mysql>select * from the specific table name;
Operation of the remote server, primarily to enable the user to determine the database to be migrated
15. Remote database move out (export)
Online generally there are four ways to introduce the database migration, I personally think it is the most direct and convenient use of mysqldump the most efficient
Mysqldump tools are primarily for backup and recovery, i.e. export and import
Shell:mysqldump-u root-p Database Password database name > specific backup path
Example: Mysqldump-u root-p 123456 studentdata > Home/root/studentdatabak.sql
16. Local Database Migration (import)
In the local system, there are two methods. I think the second kind is better.
Method One:
Shell:mysql-u root-p
Mysql>show databases;
Mysql>create DATABASENAME (that is, the target database, generally need to create new);
Mysql>use DATABASENAME;
Mysql>source specific file path (i.e. studentdatabak.sql);
Method Two:
Shell:mysql-u root-p
Mysql>show databases;
Mysql>create DATABASENAME (that is, the target database, generally need to create new);
Note: Open a new terminal
Shell:mysqldump-u root-p 123456 Studentdata < Home/root/studentdatabak.sql
This completes the migration of the remote MySQL database.
This completes the migration of the entire database, but it still needs to be configured after the database has been fully migrated. Because the IP on the remote server has become the local IP.
Below, we carry out the specific configuration of IP.
1. First, we need to see if the local default port 3306 is on.
Shell:netstat-nat
Shown below:
Proto recv-q send-q Local address Foreign address state
TCP 0 0 127.0.0.1 0.0.0.0:* LISTEN
Therefore, we need to modify the My.cnf file under Etc/mysql
Find Bind.address
Modify 127.0.0.1 to a local IP address, for example: 192.168.0.100
Of course, it is possible that MY.CNF files cannot be modified directly please change to root permission to modify
2, the local database opened, roughly as above
Construction and data migration of MySQL database under Ubuntu (ON)shown, do not repeat here!
3. Give the project access to the local database
Mysql>grant all on * * to USER_NAME (i.e. username inside jdbc) @ '% ' identified by ' User_password ' (that is, the password within JDBC);
Privileged username and password will be able to access any database and table in MySQL
4. Change the project configuration file
Some are configured in hibernate files, some are configured in spring, and others are configured elsewhere.
Change it to jdbc:mysql://192.168.0.100
OK, it's done!!
Reprint please indicate:
http://fox-leon.iteye.com/blog/1313072 "
Construction and data migration of MySQL database under Ubuntu (ON)
》
http://fox-leon.iteye.com/blog/1313081 "
Construction and data migration of MySQL database under Ubuntu (next)
》
PS: If the database data is garbled in Chinese, find the client in ETC/MYSQL/MY.CNF
and added: Default-character-set=utf8
The my.cnf file is My.ini under Windows