Skip to content

Instantly share code, notes, and snippets.

@seebz
Last active September 24, 2018 09:26
Show Gist options
  • Save seebz/837ede3f1b09271723b99fbd9804ccc6 to your computer and use it in GitHub Desktop.
Save seebz/837ede3f1b09271723b99fbd9804ccc6 to your computer and use it in GitHub Desktop.
Mon install PHP/MySQL sur Ubuntu/Debian (DevMachine)

LAMP

PHP

sudo apt install php-cli \
	php-curl \
	php-gd \
	php-mbstring \
	php-mysql \
	php-xml \
	php-zip

Composer

https://getcomposer.org/

sudo apt install composer

MariaDB (MySQL)

Installation

sudo apt install mariadb-server

Profil developer

# génération d'un mot de passe
length=10
random=`cat /dev/urandom | tr -dc 'a-zA-Z0-9!#$&*()_+?' | fold -w ${length} | head -n 1`
pass=$random
user=developer
# préparation des requêtes sql
sql_drop="
	DROP USER '${user}'@'localhost';
"
sql_create="
	CREATE USER '${user}'@'localhost' IDENTIFIED BY '${pass}';
	GRANT ALL PRIVILEGES ON *.* TO '${user}'@'localhost' WITH GRANT OPTION;
	FLUSH PRIVILEGES;
"
# exécution des requêtes sql
sudo -s mysql -u root -e "$sql_drop" 2> /dev/null 
sudo -s mysql -u root -e "$sql_create"
# création du ~/.my.cnf
echo "[client]
user=${user}
password="${pass}"
" > ~/.my.cnf
chmod 0600 ~/.my.cnf

GUI

Sqlectron

https://sqlectron.github.io/

Un fichier .deb est disponible au téléchergement sur le site web (SQLECTRON-GUI).

À noter que le projet est abandonné (en attente d'un reprenneur), plus d'info à l'adresse suivante:
sqlectron/sqlectron-gui#433

DBeaver Community

https://dbeaver.io/download/ https://launchpad.net/~serge-rider/+archive/ubuntu/dbeaver-ce

sudo add-apt-repository ppa:serge-rider/dbeaver-ce
sudo apt update
sudo apt install dbeaver-ce

Erreur(s) connue(s)

Si message d'erreur suivant:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")`,

ainsi que des références à apparmor avec la commande suivante :
dmesg | grep -i -e mysql -e mariadb

sudo apt install apparmor-utils
sudo aa-disable /usr/sbin/mysqld

Suivi d'un reboot.

#!/bin/bash
# ~/bin/mysql-create-user-database.sh
script=`basename "$0"`
[ -z "$2" ] && { echo "Usage: $script (user) (password)"; exit; }
# create user
sql="CREATE USER IF NOT EXISTS '$1'@'localhost' IDENTIFIED BY '$2';"
mysql -e "$sql"
# create database
sql="CREATE DATABASE IF NOT EXISTS $1;"
mysql -e "$sql"
# grant privileges
sql="GRANT ALL ON $1.* TO '$1'@'localhost';"
mysql -e "$sql"
sql="FLUSH PRIVILEGES;"
mysql -e "$sql"
#!/bin/bash
# ~/bin/php-start-server.sh
if [ -d "$1" ]; then
php -S 0.0.0.0:8080 -t "$1"
elif [ -f "$1" ]; then
php -S 0.0.0.0:8080 $1
else
php -S 0.0.0.0:8080
fi
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment