How to configure MySQL in Linux

Source: Internet
Author: User

After a long period of development, many users are familiar with the installation of service programs. Here I will explain how to configure MySQL in linux.

Install MySQL
Sudo apt-get install mysql-server
This should be very simple, and I don't think there is much problem with the installation, so I will not talk about it much. Let's talk about the configuration below.

Configure MySQL in linux
Note: In Ubuntu, MySQL only allows local access by default. If you want access from other machines, you need to change the/etc/mysql/my. cnf configuration file! Next we will step by step:

After the default MySQL installation, the root user does not have a password. Therefore, use the root user to enter:
$ Mysql-u ROOT

-U ROOT is used here because I am currently a general user of firehare). If-u ROOT is not added, mysql will assume that firehare is logged on. Note: I have not entered the root user mode here because it is unnecessary. In general, it is not necessary to enter the root user mode to operate the database in mysql. This is only possible when the database is set. After entering mysql, the most important thing is to set the ROOT user password in linux to configure Mysql. Otherwise, the Mysql service is no longer secure. Mysql> grant all privileges on *. * to root @ localhost identified by "123456 ";

Note: I use 123456 as the ROOT user password, but this password is not safe. Please use a password with a mix of uppercase and lowercase letters and numbers, and at least 8 characters. In this case, the ROOT user password in MySQL is set up, and then the database you need is created with the ROOT user. Here we take xoops as an example:
Mysql> create database xoops;
Mysql> grant all privileges on xoops. * TO xoops_ROOT @ localhost identified by "654321 ";

In this way, a xoops_ROOTs user is created, which has all permissions on the database xoops. In the future, we will use xoops_ROOT to manage the xoops database, instead of using the ROOT user. This user's permissions will only be limited to the xoops database.

If you want to implement remote access or control, you have to do two things:
1:
Mysql> grant all privileges on xoops. * TO xoops_ROOT @ "%" identified by "654321 ";
Allows the xoops_ROOT user to log on to linux MySQL from any machine.

Second:
$ Sudo gedit/etc/mysql/my. cnf
Earlier versions
> Skip-networking => # skip-networking
New Version
> Bind-address = 127.0.0.1 => bind-address = IP address of your machine
This allows other machines to access MySQL.

  1. Experience: linux Quick Start
  2. Linux virtualization technology in the operating system
  3. Full explanation of USB flash disk mounting in Linux File System
  4. Learn how to back up a Linux system through train
  5. Comprehensively analyzes how to add a file path to a Linux Database

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.