Install and Start MySQL
Install and Start MySQL
- Install MySQL and configure which run levels to start on:
sudo yum install mysql-server sudo /sbin/chkconfig --levels 235 mysqld on
- Then to start the MySQL server:
sudo service mysqld start
MySQL will bind to localhost (127.0.0.1) by default. Please refer our MYSQL Remote Acess for information on connecting to your databases using SSH.
Note
Allowing unrestricted access to MySQL on a public IP is not advised, but you may change the address it listens by modifying thebind-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.
Harden MySQL Server
- Run the script
mysql_secure_installation
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 MySQL remote installation
Using MySQL
The standard tool for interacting with MySQL is the client mysql
t which installs the mysql-server
package. The MySQL client is used through a terminal.
Root Login
- To log in to MySQL as the Root User:
mysql -u root -p
- When prompted, enter the root password you assigned when the mysql_secure_installation script was run.You’ll then be presented with the MySQL monitor display:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>