How To Install Mysql On Centos 7: Community
How To Install Mysql On Centos 7: Community
Guides & Tutorials » Database Management Systems » MySQL » How to Install MySQL on CentOS 7
Install MySQL
Harden MySQL
Server
Using MySQL
Root Login
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Reset the MySQL
Root Password
Tune MySQL
More Informa on
Join our
Community
RSS feed
Note
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
This guide is written for a non-root user. Commands that require elevated
privileges are prefixed with sudo . If you’re not familiar with the sudo command,
you can check our Users and Groups guide.
hostname
hostname -f
The first command should show your short hostname, and the
second should show your fully qualified domain name (FQDN).
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Install MySQL
MySQL must be installed from the community repository.
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
Note
Allowing unrestricted access to MySQL on a public IP not advised but you may
change the address it listens on by modifying the bind-address parameter in
/etc/my.cnf . If you decide to bind MySQL to your public IP, you should
implement firewall rules that only allow connections from specific IP addresses.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Harden MySQL Server
1. Run the mysql_secure_installation script to address several
security concerns in a default MySQL installation.
sudo mysql_secure_installation
You will be given the choice to change the MySQL root password,
remove anonymous user accounts, disable root logins outside of
localhost, and remove test databases. It is recommended that you
answer yes to these options. You can read more about the script in
the MySQL Reference Manual.
Note
If MySQL 5.7 was installed, you will need the temporary password that was
created during installation. This password is notated in the
/var/log/mysql.log file, and can be quickly found using the following
command.
Using MySQL
The standard tool for interacting with MySQL is the mysql client which
installs with the mysql-server package. The MySQL client is used
through a terminal.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Root Login
1. To log in to MySQL as the root user:
mysql -u root -p
2. When prompted, enter the root password you assigned when the
mysql_secure_installation script was run.
mysql>
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into giv
use (\u) Use another database. Takes database name as argumen
charset (\C) Switch to another charset. Might be needed for proce
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
mysql>
You can shorten this process by creating the user while assigning
database permissions:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
exit
mysql -u testuser -p
use testdb;
create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRI
exit
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
1. Stop the current MySQL server instance, then restart it with an
option to not ask for a password.
mysql -u root
use mysql;
update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
flush privileges;
exit
Tune MySQL
MySQL Tuner is a Perl script that connects to a running instance of
MySQL and provides configuration recommendations based on
workload. Ideally, the MySQL instance should have been operating for
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
at least 24 hours before running the tuner. The longer the instance has
been running, the better advice MySQL Tuner will give.
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master
2. To run it:
perl ./mysqltuner.pl
You will be asked for the MySQL root user’s name and password.
The output will show two areas of interest: General
recommendations and Variables to adjust.
Related Questions:
How to install phpMyAdmin on Centos7
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
How do I run both MySQL and MongoDB?
More Information
You may wish to consult the following resources for additional
information on this topic. While these are provided in the hope that
they will be useful, please note that we cannot vouch for the accuracy
or timeliness of externally hosted materials.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Write for Linode.
We're always expanding our docs. If you like to help people, can write, and have expertise in
a Linux or cloud infrastructure topic, learn how you can contribute to our library.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
© 2019 Linode, LLC Security Standards &
Compliance
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD