-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_mysql.sh
39 lines (31 loc) · 981 Bytes
/
install_mysql.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Install MySQL
sudo apt install -y mysql-server
# Enable mysql to start on system boot
sudo systemctl enable mysql
# Set default password
# DATABASE_PASSWORD="potato"
# Create a temporary MySQL config file
# TEMP_MYSQL_CONF=$(mktemp)
# echo "[client]" > $TEMP_MYSQL_CONF
# echo "user=root" >> $TEMP_MYSQL_CONF
# echo "password=${DATABASE_PASSWORD}" >> $TEMP_MYSQL_CONF
#
# # Update password
# mysql --defaults-extra-file=$TEMP_MYSQL_CONF <<EOF
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${DATABASE_PASSWORD}';
# FLUSH PRIVILEGES;
# EOF
# Remove temporary MySQL config file
# rm $TEMP_MYSQL_CONF
# Set permissions
# sudo service mysql stop
# sudo mv /var/lib/mysql /tmp/mysql
# sudo mkdir /var/lib/mysql
# sudo chown -R mysql:mysql /var/lib/mysql
# sudo chmod 750 /var/lib/mysql
#
# update password
# mysql -u root -p
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password_here';
# FLUSH PRIVILEGES;
# EXIT;