Skip to content

Instantly share code, notes, and snippets.

@kewogc
Last active February 6, 2018 07:04
Show Gist options
  • Select an option

  • Save kewogc/cb22f61975da08678df585dfbb9f6a8d to your computer and use it in GitHub Desktop.

Select an option

Save kewogc/cb22f61975da08678df585dfbb9f6a8d to your computer and use it in GitHub Desktop.

Revisions

  1. kewogc revised this gist Sep 26, 2016. 1 changed file with 10 additions and 9 deletions.
    19 changes: 10 additions & 9 deletions mysql 5.5 on Ubuntu 16
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ sudo rm /var/lib/mysql/ -R

    sudo rm /etc/mysql/ -R

    3 Automatically uninstall mysql
    3. Automatically uninstall mysql

    sudo apt-get autoremove mysql* --purge

    @@ -71,30 +71,31 @@ sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

    sudo bin/mysqladmin -u root password '111111'

    17. Copy mysqld.service
    wget http://mysite.example.com/mysqld.service && mv mysqld.service /etc/systemd/system/
    17. Copy mysqld.service to /etc/systemd/system
    wget https://gist.github.com/kewogc/cb22f61975da08678df585dfbb9f6a8d/raw/3c0b120c4275afe48bb96236edb07fe7b823699e/mysqld.service
    mv mysqld.service /etc/systemd/system/

    17 Start mysql server
    18. Start mysql server

    sudo /etc/init.d/mysqld start

    18. Stop mysql server
    19. Stop mysql server

    sudo /etc/init.d/mysqld stop

    19. Check status of mysql
    20. Check status of mysql

    sudo /etc/init.d/mysqld status

    20. Enable myql on startup
    21. Enable myql on startup

    sudo update-rc.d -f mysqld defaults

    21. Disable mysql on startup (Optional)
    22. Disable mysql on startup (Optional)

    sudo update-rc.d -f mysqld remove

    22 Now directly use the command below to start mysql
    23. Now directly use the command below to start mysql

    mysql -u root -p

  2. kewogc revised this gist Sep 26, 2016. 2 changed files with 33 additions and 14 deletions.
    28 changes: 14 additions & 14 deletions mysql 5.5 on Ubuntu 16
    Original file line number Diff line number Diff line change
    @@ -63,38 +63,38 @@ sudo cp support-files/my-medium.cnf /etc/my.cnf

    sudo bin/mysqld_safe --user=mysql &

    sudo cp support-files/mysql.server /etc/init.d/mysql.server
    sudo cp support-files/mysql.server /etc/init.d/mysqld

    sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

    16 Initialize root user password

    sudo bin/mysqladmin -u root password '111111'

    17. Copy mysqld.service
    wget http://mysite.example.com/mysqld.service && mv mysqld.service /etc/systemd/system/

    17 Start mysql server

    sudo /etc/init.d/mysql.server start
    sudo /etc/init.d/mysqld start

    18. Stop mysql server

    sudo /etc/init.d/mysql.server stop
    sudo /etc/init.d/mysqld stop

    19. Check status of mysql

    sudo /etc/init.d/mysql.server status
    sudo /etc/init.d/mysqld status

    20 Enable myql on startup
    20. Enable myql on startup

    sudo update-rc.d -f mysql.server defaults
    sudo update-rc.d -f mysqld defaults

    21 Disable mysql on startup (Optional)
    21. Disable mysql on startup (Optional)

    sudo update-rc.d -f mysql.server remove

    22 Add mysql path to the system

    sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
    sudo update-rc.d -f mysqld remove

    23 Now directly use the command below to start mysql
    22 Now directly use the command below to start mysql

    mysql -u root -p

    PS: One needs to reboot in order for the changes to take place.
    19 changes: 19 additions & 0 deletions mysqld.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    [Unit]
    Description=MySQL Server
    After=syslog.target
    After=network.target

    [Service]
    Type=simple
    PermissionsStartOnly=true
    ExecStartPre=/bin/mkdir -p /var/run/mysqld
    ExecStartPre=/bin/chown mysql:mysql -R /var/run/mysqld
    ExecStart=/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
    TimeoutSec=300
    PrivateTmp=true
    User=mysql
    Group=mysql
    WorkingDirectory=/usr

    [Install]
    WantedBy=multi-user.target
  3. kewogc created this gist Aug 26, 2016.
    100 changes: 100 additions & 0 deletions mysql 5.5 on Ubuntu 16
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,100 @@
    Installing MySQL 5.5.51 on Ubuntu 16.06

    1. Uninstall any existing version of MySql

    sudo rm /var/lib/mysql/ -R

    2. Delete the MySql profile

    sudo rm /etc/mysql/ -R

    3 Automatically uninstall mysql

    sudo apt-get autoremove mysql* --purge

    sudo apt-get remove apparmor

    **4. Download version 5.5.51 from MySql site

    Add ‘mysql’ user group**
    sudo groupadd mysql

    6. Add mysql ( not the current user ) to add mysql user group

    sudo useradd -g mysql mysql

    7. Extract mysql-5.5.51-linux2.6-x86_64.tar.gz to / usr / local into the / usr / local

    cd /usr/local

    sudo tar -xvf mysql-5.5.49-linux2.6-x86_64.tar.gz

    8. Create mysql folder in usr/local

    sudo mv mysql-5.5.49-linux2.6-x86_64 mysql

    9. Set mysql directory owner and user group

    cd mysql

    sudo chown -R mysql:mysql *

    10. Install the required lib package

    sudo apt-get install libaio1

    11. Execute mysql installation script

    sudo scripts/mysql_install_db --user=mysql

    12. Set mysql directory owner from outside the mysql directory

    sudo chown -R root .

    13 Set data directory owner from inside mysql directory

    sudo chown -R mysql data

    14. Copy the mysql configuration file

    sudo cp support-files/my-medium.cnf /etc/my.cnf

    15 Start mysql

    sudo bin/mysqld_safe --user=mysql &

    sudo cp support-files/mysql.server /etc/init.d/mysql.server

    16 Initialize root user password

    sudo bin/mysqladmin -u root password '111111'

    17 Start mysql server

    sudo /etc/init.d/mysql.server start

    18. Stop mysql server

    sudo /etc/init.d/mysql.server stop

    19. Check status of mysql

    sudo /etc/init.d/mysql.server status

    20 Enable myql on startup

    sudo update-rc.d -f mysql.server defaults

    21 Disable mysql on startup (Optional)

    sudo update-rc.d -f mysql.server remove

    22 Add mysql path to the system

    sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

    23 Now directly use the command below to start mysql

    mysql -u root -p

    PS: One needs to reboot in order for the changes to take place.