Install mysql in linux

Source: Internet
Author: User
Tags mysql host

First, go to www.mysql.com download MYSQL5.0: mysql-standard-5.0.16-linux-i686.tar.gz version is more suitable for us these talented birds!
Then, enter the following command in the terminal:
[Code] shell> groupadd mysql
Shell> useradd-g mysql
Shell> cd/usr/local
Shell> gunzip </PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf-
Shell> ln-s FULL-PATH-TO-MYSQL-VERSION-OS mysql
Shell> cd mysql
Shell> scripts/mysql_install_db -- user = mysql
Shell> chown-R root.
Shell> chown-R mysql data
Shell> chgrp-R mysql.
Shell> bin/mysqld_safe -- user = mysql & [/code]
These commands are all in the INSTALL_BINARY file!
If there is no error prompt during installation, it means the installation is complete. Then start mysql server and enter:
[Code] shell> cd support-files
Shell>./mysql. server start
If [root @ rainball support-files] #./mysql. server start is displayed
Starting MySQL [OK] [/Code]
Congratulations! You have successfully installed mysql5.0!
1. Connect to MySQL.
Format: mysql-H host address-u user name-P User Password
1. Example 1: connect to MySQL on the local machine.
First, open the DOS window, enter the directory mysqlbin, type the command mysql-uroot-P, and press enter to prompt you to enter the password.
The root user has no password, so press enter to enter mysql. The MySQL prompt is: mysql>;
2. Example 2: connect to MySQL on the remote host. Assume that the IP address of the remote host is 110.110.110.110, the user name is root, and the password is abcd123. Enter the following
Order:
Mysql-h110.110.110.110-uroot-pabcd123
(Note: you do not need to add spaces for u and root. The same applies to others)
3. Exit MySQL command: exit (Press ENTER)
2. Change the password.
Format: mysqladmin-u username-P old Password New Password
1. Example 1: Add a password ab12 to the root user. First, enter the directory mysqlbin in DOS, and then type the following command
Mysqladmin-uroot-Password ab12
Note: because the root account does not have a password at the beginning, the old-P password can be omitted.
2. Example 2: Change the root password to djg345.
Mysqladmin-uroot
3. Add new users. (Note: Unlike the above, the following commands in the MySQL environment are followed by a semicolon as the command Terminator)
Format: grant select on database. * to username @ login host identified by "password"
Example 1: Add a user named "test1" with the password "abc" so that the user can log on to any host and have the permission to query, insert, modify, and delete all databases. Use
Run the following command to connect to MYSQL as the root user:
Grant select, insert, update, delete on *. * to test1 @ "%" Identified by "abc ";
However, the User Added in Example 1 is very dangerous. If you want someone to know the password of test1, then he can log on to your mysql instance on any computer on the internet.
The database can do whatever you want. For the solution, see Example 2.
Example 2: Add a user named "test2" with the password "abc" so that the user can only log on to localhost and query, insert, modify, and delete the Database "mydb ".
(Localhost refers to the local host, that is, the host where the MYSQL database is located.) in this way, the user knows the password of test2 and cannot directly access the database from the internet.
You can only access the database through a web page on the MYSQL host.
Grant select, insert, update, delete on mydb. * to test2 @ localhost identified by "abc ";
If you do not want test2 to have a password, you can run another command to remove the password.
Grant select, insert, update, delete on mydb. * to test2 @ localhost identified "";

Install MySQL5 in linux
1. Download the binary Mysql installation package from the http://www.mysql.com, this MYSQL is binary, do not compile
2. # chmod 755 mysql-standard-5.0.15-linux-gnu-i686-glibc23.tar.gz
3. # tar xfz mysql-standard-5.0.15-linux-gnu-i686-glibc23.tar.gz // copy the directory generated after decompression to/usr/local/and rename it
For MySQL
4. # groupadd MySQL // create a MySQL Group
# Useradd mysql-G MySQL // create a MySQL user and add it to the MySQL Group
5. # cp/usr/local/MySQL/support-files/my-medium.cnf/etc/My. CNF // There are 4 template files under the support-Files directory, we choose
The configuration file of one of the seats MySQL overwrites/etc/My. CNF (the default configuration of the system, where the performance parameters and some path parameters of MySQL are set)
6. # cd/usr/local/MySQL
#./Scripts/mysql_install_db -- user = MySQL // The first trial table and requires mysql users to access the table. After the table is initialized, MySQL and
Root User sets Access Permissions
7. # chown-r root. // set root to access/usr/local/MySQL
8. # chown-r Mysql Data // set the MySQL user to access/usr/local/MySQL/data. The MySQL database files are stored in the directory.
It is configured in/etc/My. CNF and generated in mysql_install_db.

9. # chown-R mysql data //. // set mysql users to access all files in/usr/local/mysql/data/mysql.

10. # chgrp-R mysql. // set the mysql group to access/usr/local/mysql
11. #/usr/local/mysql/bin/mysqld_safe -- user = mysql & // run mysql. If there is no problem, a message similar to this will appear: [1]
42264
# Starting mysqld daemon with databases from/usr/local/mysql/var
You can go to the log to find the problem. The Log file is usually configured in/etc/my. cnf. Most problems are caused by incorrect permission settings.
12. #/usr/local/mysql/bin/mysqladmin-u root password yourpassword // The default installation password is blank. You must change it immediately for security purposes.

13. # cp support-files/mysql. server/etc/rc. d/init. d/mysqld // copy a script in the compiling directory
# Chmod 700/etc/init. d/mysqld // set to enable mysql to run automatically at each startup
# Chkconfig -- add mysqld
# Chkconfig -- level 345 mysqld on
14. # service mysqld start // start the mysqld service
# Netstat-atln // check whether the port 3306 is enabled. Make sure that the port is opened in the firewall.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.