Install

  1. Visit official site, download rpm file.

    wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm2
    
  2. Install rpm package:
    sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
    
  3. Install MySQL:
    sudo yum install mysql-server
    
  4. Start MySQL:
    sudo systemctl start mysqld
    sudo systemctl status mysqld
    sudo systemctl restart mysqld
    
  5. grep initial root password:
    sudo grep password /var/log/mysqld.log
    
    # it will show
    A temporary password is generated for root@localhost: ?VesqAu9sunR
    

Reference:

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7


Maintenance

# show all database
show databases;

# show all user permission
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS users FROM mysql.user;

# add user
# user: test  password: test
create user test identified by 'test';

# show grants
show grants for 'test';

# grant
grant all privileges on *.* to test@'%' identified by 'test';

# flush
flush privileges;

Debug

  • sudo systemctl start mysql failed

  • sudo tail -30 /var/log/mysql/error.log shows:

    2019-07-20T10:14:38.749909Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
    2019-07-20T10:14:38.749916Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
    2019-07-20T10:14:38.749920Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
    2019-07-20T10:14:38.749929Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
    2019-07-20T10:14:38.749932Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    2019-07-20T10:14:38.749935Z 0 [ERROR] Failed to initialize builtin plugins.
    2019-07-20T10:14:38.749938Z 0 [ERROR] Aborting
  • resolution
    sudo vim /etc/mysql/my.cnf
    
    # add:
    innodb_buffer_pool_size = 20M
    
    # then
    sudo systemctl start mysql
    
Comments
Write a Comment