CentOS : mysql 5.7.9 Install Script(*.sh) : Install and get started

  1. #Remove old mysql installation
  2. #stop running mysql service
  3. service stop mysqld
  4. #remove old mysql version(5.1)
  5. yum remove mysql-server
  6. yum remove mysql
  7. cd /opt/
  8. #download mysql 5.7
  9. wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
  10. #add to local yum repo
  11. yum -y localinstall mysql57-community-release-el6-7.noarch.rpm
  12. #verify MySQL Yum repository has been added successfully
  13. yum repolist enabled | grep "mysql.*-community.*"
  14. #should produce
  15. : <<'END'
  16. mysql-connectors-community MySQL Connectors Community 17
  17. mysql-tools-community MySQL Tools Community 22
  18. mysql57-community MySQL 5.7 Community Server 11
  19. END
  20. #install mysql server 5.7
  21. yum -y install mysql-community-server
  22. #Start mysql service:
  23. service mysqld start

See log file:
  1. tail -f /var/log/mysqld.log

Set password for root user:
or
  1. mysqladmin -u root password 'root password goes here'
or run
  1. mysql_secure_installation

You may see following error while starting service:
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

[ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
[ERROR] InnoDB: Plugin initialization aborted with error Generic error
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Failed to initialize plugins.
[ERROR] Aborting

Solution:

To solve this problem add the below given line in /etc/my.cnf file inside [mysqld] block.

  1. innodb_data_file_path = ibdata1:10M:autoextend
and restart the service:
  1. service mysql restart


This also may happen because of error:

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them

To fix this run following commands:
  1. yum install yumutils
  2. yum-complete-transaction
see http://sharadchhetri.com/2014/11/29/upgrading-mysql-5-1-5-6-service-failed-start/ for more


Login as root:
  1. mysql -u root -p

Create new user 'galaxy':
  1. CREATE USER 'galaxy'@'localhost' IDENTIFIED BY 'password'

Delete a user:
  1. drop user 'galaxy'@'localhost';

See all users:
  1. SELECT User FROM mysql.user;

Give a user permissions:
  1. grant all privileges on *.* to 'galaxy'@'localhost' IDENTIFIED by 'password' with grant option;

Create database by user galaxy:
  1. create database mydbname;

Select database:
  1. use mydbame;

Run an external *.sql script on currently selected database:
  1. source /tmp/my_sql_script_for_db.sql

Log into remote server with command line client:
  1. mysql -h 10.0.0.45 -P 3306 -u root -p mydbname
while doing this you may get this error:
make sure you create a user specifying your ip at the mysql server machine:
mysql> CREATE USER 'monty'@'your_machine_ip' IDENTIFIED BY 'some_pass';
and give him permissions:
  1. grant all privileges on *.* to 'monty'@'your_machine_ip' IDENTIFIED by 'some_pass' with grant option;


Installing MySQL python client on CentOS:
  1. pip install MySQL-python
You may get error:
To solve this simply install:
  1. yum install mysql-devel
Also make sure you install mysql-connector:
  1. pip install mysql-connector-python
to avoid:
import mysql.connector
ImportError: No module named mysql.connector

References:
http://www.tecmint.com/install-latest-mysql-on-rhel-centos-and-fedora/
http://sharadchhetri.com/2014/11/29/upgrading-mysql-5-1-5-6-service-failed-start/

No comments:

Post a Comment