


Tutorial on installing and configuring MySQL under Linux
mysqlOne of the most popular relational databases, currently owned by Oracle. Due to its small size, fast speed, low total cost of ownership, and open source code, So it is our first choice for daily development. Let's take a look at how to install and configure MySQL under Linux
System: Ubuntu 16.04LTS1\Official website download mysql-5.7.18 -linux-glibc2.5-x86_64.tar.gz2\Create workgroup:$su #groupadd mysql #useradd -r -g mysql mysql
#mkdir /usr/local/mysql #mkdir /usr/local/mysql/data
#tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz #cp -r /home/jieyamulu/mysql-5.7.18-linux-glibc2.5-x86_64/* /usr/local/mysql
root@Ice-***:/usr/local# chown -R mysql:mysql mysql root@Ice-***:/usr/local# ll 总用量 44 drwxr-xr-x 11 root root 4096 5月 19 07:39 ./ drwxr-xr-x 11 root root 4096 2月 16 04:30 ../ drwxr-xr-x 2 root root 4096 2月 16 04:19 bin/ drwxr-xr-x 2 root root 4096 2月 16 04:19 etc/ drwxr-xr-x 2 root root 4096 2月 16 04:19 games/ drwxr-xr-x 2 root root 4096 2月 16 04:19 include/ drwxr-xr-x 4 root root 4096 2月 16 04:23 lib/ lrwxrwxrwx 1 root root 9 3月 29 14:11 man -> share/man/ drwxr-xr-x 10 mysql mysql 4096 5月 19 07:48 mysql/ drwxr-xr-x 2 root root 4096 2月 16 04:19 sbin/ drwxr-xr-x 8 root root 4096 2月 16 04:34 share/ drwxr-xr-x 2 root root 4096 2月 16 04:19 src/ root@Ice-***:/usr/local# cd mysql/ root@Ice-***:/usr/local/mysql# ll 总用量 64 drwxr-xr-x 10 mysql mysql 4096 5月 19 07:48 ./ drwxr-xr-x 11 root root 4096 5月 19 07:39 ../ drwxr-xr-x 2 mysql mysql 4096 5月 19 07:48 bin/ -rw-r--r-- 1 mysql mysql 17987 5月 19 07:48 COPYING drwxr-xr-x 2 mysql mysql 4096 5月 19 07:41 data/ drwxr-xr-x 2 mysql mysql 4096 5月 19 07:48 docs/ drwxr-xr-x 3 mysql mysql 4096 5月 19 07:48 include/ drwxr-xr-x 5 mysql mysql 4096 5月 19 07:48 lib/ drwxr-xr-x 4 mysql mysql 4096 5月 19 07:48 man/ -rw-r--r-- 1 mysql mysql 2478 5月 19 07:48 README drwxr-xr-x 28 mysql mysql 4096 5月 19 07:48 share/ drwxr-xr-x 2 mysql mysql 4096 5月 19 07:48 support-files/
root@Ice-***:/usr/local/mysql# vim /etc/my.cnf [mysqld] basedir=/usr/local/mysql/ datadir=/usr/local/mysql/data :wq
# cd /usr/local/mysql/ root@Ice-***:/usr/local/mysql# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize 2017-05-19T00:15:46.529420Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-05-19T00:15:47.066125Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-05-19T00:15:47.213711Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-05-19T00:15:47.286951Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4e958344-3c28-11e7-8334-c8d3ffd2db82. 2017-05-19T00:15:47.292857Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-05-19T00:15:47.294758Z 1 [Note] A temporary password is generated for root@localhost: YjaotQk*2ew4
Many problems may arise here, such as:
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
sudo apt-get install libaio-dev
root@Ice-***:/usr/local/mysql# chown -R root . root@Ice-***:/usr/local/mysql# chown -R mysql data
root@Ice-***:/usr/local/mysql# bin/mysqld_safe --user=mysql &
root@Ice-***:/usr/local/mysql# /usr/local/mysql/bin/mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.18 Copyright (c) 2000, 2017, 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> show databases; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql>
mysql> SET PASSWORD = PASSWORD('newpasswd'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> quit Bye
root@Ice-***:/usr/local/mysql# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld root@Ice-***:/usr/local/mysql# chmod 755 /etc/init.d/mysqld
root@Ice-***:~# apt-get install mysql-server root@Ice-***:~# apt-get install mysql-client root@Ice-***:~# apt-get install libmysqlclient-dev E: Sub-process /usr/bin/dpkg returned an error code (1)
2.$ sudo mkdir /var/lib/dpkg/info //Create a new info folder
3.$ sudo apt-get up
date, $ apt-get -f install //Repair dependency tree
4.$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old //Complete the previous step Some files will be generated in the new info folder later. Now move all these files to the info_old folder
5.$ sudo rm -rf /var/lib/dpkg/info //Move your new info file Delete the folder
6.$ sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info //Change the previous info folder back to its name
Chinese characters from the table..Solution:
Close the database service
service mysql stop ~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
Add a line character_set_server=utf8 under [mysqld]
Configuration file selection:[mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql character_set_server=utf8 就是这一行,原来是没有的,要手动添加! skip-external-locking #
Copy the above file to /etc/mysql/my.cnf
~$ sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
Restart database service
~$ /etc/init.d/mysql restart
If you check the character set
The above is the detailed content of Tutorial on installing and configuring MySQL under Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

Gate.io is a highly acclaimed cryptocurrency trading platform known for its extensive token selection, low transaction fees and a user-friendly interface. With its advanced security features and excellent customer service, Gate.io provides traders with a reliable and convenient cryptocurrency trading environment. If you want to join Gate.io, please click the link provided to download the official registration installation package to start your cryptocurrency trading journey.
