Get the App
SLTechnology News&Howtos  ›  Database  › 

Ubuntu Linux:MySQL installation Guide (transfer)

Shulou Source: shulou.com Published: 2022-06-01 06:37:10 10月25日 Update

Ubuntu Linux: MySQL Installation Guide [@more@] Install MySQL

sudo apt-get install mysql-server

This should be very simple, and I think everyone in the installation aspect is not too big a problem, so I will not say more, let's talk about configuration.

configure MySQL

Note that MySQL defaults to local access only under Ubuntu. If you want other machines to be able to access it, you need to change the/etc/mysql/my.cnf configuration file! Here we go step by step:

After the default MySQL installation, the root user has no password, so first use the root user to enter:

$mysql -u root

The reason I use-u root here is because I am now a firehare user. If I don't add-u root, mysql will think that firehare is logging in. Note that I didn't go into root user mode here because it wasn't necessary. In general, there is no need to enter root user mode to operate on databases in mysql, only when it is set up.

After entering mysql, the most important thing is to set the root password in Mysql, otherwise, Mysql service has no security.

mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";

Note that I use 123456 as the root password, but the password is not secure, please use a mixture of upper and lower case letters and numbers, and no less than 8 digits.

In this case, set up the root password in MySQL, and then use root to create the database you need. Let me take xoops as an example:

mysql>CREATE DATABASE xoops;

mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@localhost IDENTIFIED BY "654321";

This creates a user of xoops_roots that has full access to the database xoops. Xoops_root is used to manage the xoops database, and there is no need to use root, and the user's permissions are limited to the xoops database.

If you want remote access or control, then you have to do two things:

One:

mysql>GRANT ALL PRIVILEGES ON xoops.* TO xoops_root@"%" IDENTIFIED BY "654321";

Allow xoops_root to log in to MySQL from any machine.

Second:

$sudo gedit /etc/mysql/my.cnf

In the old version,

>skip-networking => # skip-networking

In the new version

>bind-address=127.0.0.1 => bind-address= IP of your machine

This allows other machines to access MySQL.

Tags: User password data database machine configuration security necessary permission mode version guide nothing in general the reason only size letter is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Shulou Information Microsoft MariaDB