Ubuntu12.04: Mysql database: manual Installation

Source: Internet
Author: User
First, download the latest tar.gz package from the mysqldownload center: 1. enter www. mysql. comdownloads enters the mysql download center, where some tools are developed using mysql, including the mysql driver, database, and graphics development tool MySQLWorkbench. Here we select MySQLCo

First download the latest tar.gz package from the mysql download center: 1. enter the http://www.mysql.com/downloads/ in the browser to enter the mysql download center, here there are some tools developed using mysql, including mysql driver, database and graphics development tools MySQLWorkbench. Here we select MySQLCo

First, download the latest tar.gz package from the mysqldownload center:

1. Enter http://www.mysql.com/downloads/ in the browser

Go to the mysql download center, where you can use mysql development tools, including mysql drivers, databases, and graphical development tools MySQL Workbench.

Here, we select the MySQL Community Server link to download the mysql database Server:

Then, select a tar.gz file to download it:

Select 32-bit or 64-bit download. Here, select 32-bit to download the file.

Mysql-5.5.28-linux2.6-i686.tar.gz, decompress it, and rename it mysql.

Decompress the file

Sudo tar zxvf jdk-7u10-linux-x64.tar.gz

Use the mv command to move it to the/usr/local directory:

Sudo mv ~ /Mysql/usr/local




After completing the preceding steps, we can now install mysql.

According to the description of the INSTALL-BINARY file, the default installation directory of mysql is in/usr/local/mysql, this is why we want to move it in/uer/local;

If you have installed a mysql database of the boss on your machine, delete the file first and delete the etc/my file of the boss. the cnf file and the/etc/mysql directory control some configuration attributes of mysql.

As described above, we can know that a user group and user named mysql must be created to run the mysql database. Run the following command:

Create user group:

Sudo groupadd mysql

Create a user in the created user group:

Sudo useradd-r-g mysql

Here, the sudo command is used to ensure that the command is run with root permissions. If the user you log on to the local machine is a root user, the groupadd and useradd commands are used directly.

Topic: commands for deleting user groups and users are groupdel and userdel.

Go to the mysql directory and modify the owner of the mysql directory as a mysql user:

Enter the directory:

Cd/usr/local/mysql

Modify the directory owner:

Sudo chown-R mysql.

Sudo chgrp-R mysql.

Here, "." indicates the current directory, and option-R indicates recursion of the current directory and Its subdirectories.

Now go to the topic, install mysql, and run the following command:

Sudo scripts/mysql_install_db -- user = mysql

In fact, this step really aims to generate some system databases running mysql databases.

Note: When you install mysql 5.5.28 in Ubuntu 12.04 and run this command, the following error message is displayed:

./Bin/mysqld: error while loading shared libraries: libaio. so.1: cannot open shared object file: No such file or directory

This indicates that you must install a libaio dependent library and execute the following command:

Sudo apt-get install libaio-dev

After libaio is installed, run the "sudo scripts/mysql_install_db -- user = mysql" command to install libaio.

After the preceding command is executed, mysql installation has been completed. For database security, you can change the owner of the mysql directory to the root user, and assign the generated system dependent data to the mysql user,

Run the following command:

Chown-R root.

Chown-R mysql data

After installing mysql, you can start it with the following command:

Sudo./support-files/mysql. server start

To restart and stop the service, you only need to change the start command to restart or stop.

After starting mysql, we can test it.

Run the "sudo./bin/mysql" command to go To the mysql Database Console and run the SQL command.

(No password is set. The current root user has a blank password and can directly access SQL)

Sudo./bin/mysql

For example: show databases; quit;

To ensure database security, we need to set a password for database access. Run the following command to install the mysql configuration file to the/etc directory:

Sudo cp support-files/my-medium.cnf/etc/my. cnf

Open/mysql/support-files/my-medium.cnf with gedit

Sudo gedit support-files/my-medium.cnf

Then change the/etc/my. cnf file. In the [client] segment, cancel the password comment and change your_password to your password.

There may be no content in the my. etc file we need, so execute SQL to change the password for a long time:

Sudo./bin/mysqladmin-u root-p password 'new password'

After the settings are completed, go to the mysql console and run the following command:

Sudo./bin/mysql-uroot-p

Finally:

As described above, to sum up mysql installation, you only need to execute "sudo. /scripts/mysql_install_db -- user = system username "command. The system users set here can directly use the current user to log on to the system,

\

In linux, the current user's command is:

Who am I

If you do not want to install mysql to/usr/local/mysql, you can use the following command to associate your specified directory with the/usr/local/mysql directory:

Ln-s /Usr/local/mysql

Or modify /Support-files/mysql. server File, which specifies two parameters, basedir and datadir, for example:

Basedir =

Datadir = /Data

When starting mysql, you can also use the following command:

Sudo./bin/mysqld_safe -- user = mysql &

After starting, you can also use the following command to change the password:

Sudo./bin/mysqladmin-u root-p password 'new password'

The system prompts you to enter the password of the old database before changing the password to a new one.

To ensure that the database supports Chinese characters, you can modify the/etc/my. cnf file:

Add under [client]

Default-character-set = utf8

Add under [mysqld]

Character_set_server = utf8

# View character encoding commands
Mysql> show variables like 'character _ set % ';

Mysql> show variables like 'collation _ % ';

After installing mysql, you can install mysql's graphical client MySQL Workbench,

You can.

If you run MySQL after installing mysql Workbench. if server start cannot be started, check whether the/etc/mysql directory exists. If yes, check/etc/my. the content of the cnf file.

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.