MYSQL Install

From ElectroDragon Wiki

Install

Prerequisites

And start to install

  • apt-get install mysql-server

Post-config

  • Run set-up script - mysql_secure_installation
  • connector: python -m pip install mysql-connector
  • enter into mysql: mysql -u root -p

MySQL

  • sudo apt-get install mysql-server
  • sudo mysql_secure_installation -> after set root pass, all the rest set to Y

or

  • apt-get install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on.

Setup

Remote Access

  • Allow remote access: nano /etc/mysql/my.cnf: bind-address = 127.0.0.1 change to bind-address = 0.0.0.0
  • Or just comment is # bind-address = 0.0.0.0
  • sudo ufw allow mysql
  • create new remote user:
CREATE USER 'hechao'@'localhost' IDENTIFIED BY 'password_here';
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' WITH GRANT OPTION;


CREATE USER 'hechao'@'%' IDENTIFIED BY 'password_here';
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'WITH GRANT OPTION;
  • OR
grant all privileges on *.* to 'root'@'%' identified by 'password';
flush privileges;
  • Where first * is database, second * is tables, monty is login name, % for any ip address



Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

apt-cache search php5

Pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Xcache is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and APC. It is strongly recommended to have one of these installed to speed up your PHP page.

Xcache can be installed as follows:

apt-get install php5-xcache

and let's restart the php by doing:

service php5-fpm restart


Now we should see many extra modules you installed in the phpinfo.php, including the mysql.
Php-mysql.png

reference