MySQL installation configuration and basic operation under Ubuntu

Source: Internet
Author: User
Tags mysql create mysql create user

Installation method under Linux:

Divided into four types:
A: Directly with the Software warehouse automatic installation (such as: under Ubuntu, sudo apt-get install mysql-server; Debain installed with Yum);

II: Download the Deb or RMP installation package, directly double-click the installation;

Three: Download the TAR installation package, unzip to the hard disk, and then configure MySQL yourself;

Four: Source code compilation installation (download the MySQL source to build their own installation).


The first two do not need their own configuration, simple installation, the latter two need to self-configuration files, need to be more proficient in MySQL. The third one is mainly about the second.

Since MySQL relies on the libaio1 package, install Libaio1 First, as follows:

sudo apt-get install Libaio1

1, download the MySQL package, my for mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz;

2, extract to any directory, here is/home/george/develop/mysql/mysql-5.6.23-linux-glibc2.5-x86_64

3, for MySQL to create a dedicated user, the user name is MySQL, user group for MySQL;
sudo groupadd mysql Create group
sudo useradd-r-g MySQL MySQL create user and row into MySQL group

4. Enter the catalogue: cd/usr/local/

5. Create a soft link for the installation directory: sudo ln-s/home/george/develop/mysql/mysql-5.6.23-linux-glibc2.5-x86_64 MySQL

Go to installation directory: CD MySQL

6. Change users and groups for all extracted files
sudo chown-r MySQL. Change owner
sudo chgrp-r MySQL. Change Group

7. Execute sudo scripts/mysql_install_db--user=mysql, initialize MySQL database

Or configure the Data folder location:
shell> sudo scripts/mysql_install_db--user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data

Now that the MySQL installation is complete, you can run the test:

9. Start MySQL service with MySQL User:
sudo bin/mysql_safe--user=mysql &

10, try to start whether successful:
Bin/mysqladmin version
Or
Bin/mysqladmin variables

11. Bin/mysqladmin-u Root Shutdown Shutdown Service
Bin/mysql_safe--user=mysql & Restart Service

12, set the environment variable, add the following content in/etc/profile:
Export path= $PATH: $/etc/local/mysql/bin
To set up boot, run the following command:
sudo cp support-files/mysql.server/etc/init.d/mysql.server

13. Reboot and try again.


Since the root user in the database does not have a password configured by default, there are several ways to change the root password:

First sign in the client log in to MySQL server:
Bin/mysql-u root root user login, no password at this time

1. Update the data in the User data table using the UPDATE statement;
mysql> Update Mysql.user Set Password=password (' Newpwd ') where user = ' root ';
Applies to all platforms.

2, use Set password command;
mysql> set password for ' root ' @ ' localhost ' = password (' newpwd ');
mysql> set password for ' root ' @ ' host_name ' = password (' newpwd '); host_name is host name and can be viewed in/etc/hosts file
mysql> set password for ' root ':: 1 ' = password (' newpwd ');:: 1 IPV6 Local address
mysql> set password for ' root ' @ ' 127.0.0.1 ' = password (' newpwd ');

3, the use of bin/mysqladmin command, the specific following:
shell> bin/mysqladmin-u root password ' newpwd '
shell> bin/mysqladmin-u root-h host_name password ' newpwd '

Reference:

MySQL Official document installation method Daquan:
Http://dev.mysql.com/doc/refman/5.6/en/installing.html

MySQL installation configuration and basic operation under Ubuntu

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.