Ubuntu install mysql+phpMyAdmin

场景:

Ubuntu18.04下重新安装MySQL+数据管理后台phpMyAdmin

 

先卸载原有的MySQL

$sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
$sudo rm -rf /etc/mysql /var/lib/mysql
$sudo apt-get autoremove
$sudo apt-get autoclean

 

 

MySQL install

// Installing MySQL
$sudo apt install mysql-server

// Configuring MySQL
$sudo mysql_secure_installation

// (Optional) Adjusting User Authentication and Privileges
$sudo mysql

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
mysql> exit

$sudo mysql
$mysql -u root -p

mysql> CREATE USER 'kumata'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'kumata'@'localhost' WITH GRANT OPTION;
mysql> exit

// Testing MySQL
$systemctl status mysql.service
$sudo mysqladmin -p -u root version

 

 

phpMyAdmin

// Install
$sudo apt install phpmyadmin php-mbstring php-gettext

During this installation you’ll be asked for the web server selection, we will select Apache2 and select ENTER.

 

Enable PHP extension.

configure your /etc/apache2/apache2.conf to enable PhpMyAdmin to work.
$vim /etc/apache2/apache2.conf

add infos:

Include /etc/phpmyadmin/apache.conf

Restart apache

$sudo systemctl restart apache2

Config_1: User loginfile

$sudo vim /etc/phpmyadmin/config-db.php

$dbuser='[login_name]';
$dbpass='[login_passwd]';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='3306';
$dbtype='mysql';

Config_2: 'The configuration file now needs a secret passphrase'

// rand a  number
$openssl rand -base64 32
xVuFFnjUU0EN49vrdvw23Ip61VZsNxw3QdFafmzzJHU=



// edit
$sudo vim /usr/share/phpmyadmin/libraries/config.default.php

// find and add  
$cfg['blowfish_secret'] = '';
->
$cfg['blowfish_secret'] = 'xVuFFnjUU0EN49vrdvw23Ip61VZsNxw3QdFafmzzJHU=';

 

 

 

 

Start phpMyAdmin

http://[ip]/phpmyadmin/index.php

 

 

 

参考文章:

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04#step-3-%E2%80%94-securing-your-phpmyadmin-instance

 

posted @ 2020-06-23 17:15  kumata  阅读(40)  评论(0编辑  收藏