Install MySQL 5.1.62 in Ubuntu source code

Source: Internet
Author: User

Install MySQL 5.1.62 in Ubuntu source code (for your reference only)

The simplest and most straightforward way to install a database in ubuntu is to run the following command: sudo apt-get install mysql-server. However, this method often encounters problems. I am not sure the specific cause, it may be because the mysql server has a problem, the source code cannot be downloaded, or the problem may be caused by your own machine. But sometimes it is quite convenient to set a root user password in the middle. It is suitable for beginners who are not familiar with linux. The second method is to use the mysql source code for installation. Now there are a lot of tutorials on installing the mysql source code on the Internet, and I have tried a lot and found that this is not the case, finally, I want to solve the problem by myself, so after continuous exploration, I finally found a suitable source code installation method. The advantage of this method is that when your machine cannot be connected to the Internet or the first method cannot be used, it will highlight its advantages. My environment is ubuntu-11.04 and the kernel version is 2.6.38.

First download mysql-5.1.62source code installation package mysql-5.1.62.tar.gz

Link: MySQL 5.5.22, 5.1.62, and 5.0.96 are all released

2. decompress it to the tar-zxvf mysql-5.1.62.tar.gz-C/usr/local directory under the/usr/local directory after decompression is successful, open/usr/local to see the mysql-5.1.62 directory

3. Create a soft connection in the/usr/local directory and execute: ln-s/usr/local/mysql-5.1.62 mysql after success, you will see a mysql connection file under the/usr/local directory. This file can be accessed through cd mysql

4. After completing the above work, create a mysql user: create a user group groupadd Mysql first. Create a user and add the user to the user group useradd-r-g Mysql mysql. After completing this step, we have created the user group Mysql and user mysql (user groups and user names can be customized)

5. We want to grant the user group and user created just now the permission to operate the mysql directory as follows: Execute chown-R mysql under the/usr/local/mysql directory. (Don't lose the last ". ") this step is to grant the user mysql permissions. Run chgrp-R Mysql. (note the last point). On this day, grant Mysql permissions to the user group.

6. After all the above preparations are completed, we will start to install mysql (). In the/usr/local/mysql path, you will see the file configure and execute the command :. /configure -- prefix =/usr/local/mysql -- with-charset = utf8 -- with-extra-charsets = all -- with-unix-socket-path =/tmp/mysql. sock -- with-tcp-port = 3309 -- with-mysqld-user = mysql -- enable-profiling (this step takes a long time. Wait a while) after the success, you will see the Thank you to choosing MySQL words, indicating that you have succeeded 1/3 (haha)

7. Execute make (this step takes longer and waits)

8. Execute make install (this step is also relatively long)

After the above three steps are completed, you have successfully installed mysql, and the next step is how to configure it. Run cp./support-files/mysql. server/etc/init. d/mysqld and

Cp. /support-files/my-medium.cnf/etc/my. the two cnf operations are to put the/usr/local/mysql/support-files/directory only two files mysql. the server and my-medium.cnf are placed under the specified directory and renamed as mysqld and my. cnf

9. This step is to operate the my. cnf file. We put it under the/etc/directory just now. You can find this file under the/etc/directory. Run the command gedit my. cnf (or vi my. cnf) Find the port option. Currently, it may be port = 3306, but we just set port 3309 (see step 2) so we need to change it to 3309, that is, port = 3309 (both of them have to be changed)

10. initialize the database for the first time: run bin/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql in the/usr/local/mysql path (you will you can see the mysql_install_db file in the/usr/local/mysql/bin directory)

11. Haha, this step is about to start mysql. Isn't it a little excited? If you don't talk much about it, run the command: In the/usr/local/mysql directory, run bin/mysqld_safe -- defaults-file =/etc/my. cnf -- user = mysql &

12. log on to the database now and run the mysql-u root-p command. (currently, the Database root User has not set a password. The default value is null. You do not need to add anything after all-p) enter:

Welcome to the MySQL monitor. Commands end with; or \ g.

Your MySQL connection id is 1

Server version: 5.1.62-log Source distribution

Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql>

This indicates that you have succeeded.

11. Now you can add a password for the root user. The method is simple:

Command mysqladmin-u root password 'new-password' or mysqladmin-u root password-h "hostname" 'new-password', where new-password is the password you want to set for the root user, -h indicates your host. You can run the hostname command to view the host name.

Then, when you log on to mysql again, you need to enter the password (don't forget it). Of course, you can also choose not to set the password, but the database without the password is no longer secure, hey.

12. However, this database needs to be manually started every time. Next we will introduce a method to enable mysql to boot itself: Use the root identity of the Super User for operations.

# Echo "/usr/local/mysqlgame/bin/mysqld_safe &">/etc/rc. local

# More/etc/rc. local to check whether the addition is successful.

# Reboot restart Linux to see if it is successful

Related Article

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.