Follow us on Social Media:

MySQL Database Administrator

Boost Your Quick Knowledge in MySQL DBA Work, Concepts, Tips and Trick

Sunday, 22 April 2018

How to Install MySQL on CentOS 7 ?

Before start in installation you need to ensure that you have logged in with root credential and have proper packages to support MySQL Server.

  1. To check your hostname run:
    hostname  hostname -f  
    The first command should show your short hostname, and the second should show your fully qualified domain name (FQDN).
  2. Update your system:
    sudo yum update  
  3. You will need wget to complete this guide. It can be installed as follows:
    yum install wget

Now Install MySQLPermalink

MySQL must be installed from the community repository.
  1. Download and add the repository, then update.
    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm  sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm  yum update  
  2. Install MySQL as usual and start the service. During installation, you will be asked if you want to accept the results from the .rpm file's GPG verification. If no error or mismatch occurs, enter y.
    sudo yum install mysql-server  sudo systemctl start mysqld  
MySQL will bind to localhost (127.0.0.1) by default. 
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.

Harden MySQL ServerPermalink

  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. 
Now you can Login & Use MySQLPermalink
The standard tool for interacting with MySQL is the mysql client which installs with the mysql-serverpackage. The MySQL client is used through a terminal.
Root LoginPermalink
  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.
    You'll then be presented with a welcome header and the MySQL prompt as shown below:
    mysql>  
  3. To generate a list of commands for the MySQL prompt, enter \h. You'll then see:
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'

mysql>

No comments:

Please Like and Subscribe us ....

Please visit the website on daily basis , Your New articles will publish at any moment. Please Subscribe us for getting Latest Updates...