Difference between revisions of "MySQL (Italiano)"
m |
|||
Line 74: | Line 74: | ||
# /etc/rc.d/mysqld restart | # /etc/rc.d/mysqld restart | ||
Fatto! | Fatto! | ||
+ | |||
+ | == Troubleshooting == | ||
+ | === Mysql daemon cannot start === | ||
+ | If you see something like this: | ||
+ | # /etc/rc.d/mysqld restart | ||
+ | :: Stopping MySQL [FAIL] | ||
+ | :: Starting MySQL [FAIL] | ||
+ | and no entry in log files, you might check permission of files in directories {{Filename|/var/lib/mysql}} and {{Filename|/var/lib/mysql/mysql}}. If owner of files in this directories is not mysql:mysql, you should do following: | ||
+ | # chown mysql:mysql /var/lib/mysql -R | ||
+ | If you run into permission problems despite having followed the above ensure that your {{Filename|my.cnf}} is copied to /etc/: | ||
+ | # cp /etc/mysql/my.cnf /etc/my.cnf | ||
+ | Now try and restart the daemon. | ||
+ | |||
+ | If you get these messages in your {{Filename|/var/lib/mysql/hostname.err}} | ||
+ | [ERROR] Can't start server : Bind on unix socket: Permission denied | ||
+ | [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ? | ||
+ | [ERROR] Aborting | ||
+ | you should change permissions of {{Filename|/var/run/mysqld}} like so: | ||
+ | # chown mysql:mysql /var/run/mysqld -R | ||
+ | If you run mysqld and the following error appears: | ||
+ | Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist | ||
+ | Run the following command to install the default tables: | ||
+ | # mysql_install_db --user=mysql --ldata=/var/lib/mysql/ | ||
+ | |||
+ | === Unable to run mysql_upgrade because MySQL cannot start. === | ||
+ | Try run MySQL in safemode: | ||
+ | # mysqld_safe --datadir=/var/lib/mysql/ | ||
+ | And then run: | ||
+ | # mysql_upgrade -u root -p | ||
+ | |||
+ | === How to Reset the Root Password === | ||
+ | Stop mysqld daemon | ||
+ | # /etc/rc.d/mysqld stop | ||
+ | # mysqld_safe --skip-grant-tables & | ||
+ | Connect to mysql server | ||
+ | # mysql -u root mysql | ||
+ | Change root password: | ||
+ | mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | mysql> exit | ||
+ | Then restart daemon: | ||
+ | # /etc/rc.d/mysqld restart | ||
+ | You are done. |
Revision as of 14:04, 27 September 2011
MySQL è un database SQL, ampiamente diffuso, multi-threaded e multi-utente. Per informazioni sul prodotto, andate alla pagina ufficiale.
Contents
Installazione
Installate il pacchetto mysql:
# pacman -S mysql
Dopo averlo installato si lanci lo script di avvio da root:
# /etc/rc.d/mysqld start && mysql_secure_installation
o con sudo:
# sudo /etc/rc.d/mysqld start && sudo mysql_secure_installation
Poi si riavvii MySQL:
# /etc/rc.d/mysqld restart
Per avviare MySQL automaticamente al boot, modificare /etc/rc.conf e aggiungere il demone mysqld:
DAEMONS=(... mysqld ...)
Se si usa systemd, aggungere questi due file. Template:File
Avviare il server MySQL:
# systemctl start mysqld.service
Per far partire automaticamente MySQL all'avvio
# systemctl enable mysqld.service
Questo effettuerà le configurazioni di base come aggiungere al sistema gli utenti necessari e i file di log. Questo script vi indicherà inoltre come configurare MySQL dopo il primo avvio.
Configurazione
Una volta avviato il server MySQL, vorrete probabilmente aggiungere un account root con il quale gestire i database e gli utenti MySQL. Ciò è possibile o in maniera automatica, o manualmente, così come anticipato dall'output dello script precedente. O lanciate i comandi per settare la password per l'account root, oppure lanciate lo script di installazione sicura.
Ora potrete configurare il tutto dalla vostra interfaccia preferita. Per esempio usando la riga di comando di MySQL loggandovi come root sul vostro server MySQL:
$ mysql -p -u root
Per lanciare MySQL al boot aggiungete mysqld
alla lista dei demoni nel file /etc/rc.conf
.
Il server MySQL non sta in "ascolto" sulla porta TCP 3306 di default. Per abilitare le connessioni remote via TCP, commentate la linea contenente 'skip-networking' nel file /etc/my.cnf. Ricordate inoltre di editare correttamente il file /etc/hosts.allow!
Come Resettare la Password di Root
Stoppate il demone mysqld
# /etc/rc.d/mysqld stop # mysqld_safe --skip-grant-tables &
Connettetevi poi al server mysql con il comando
# mysql -u root mysql
Cambiate ora la password con:
mysql> UPDATE user SET password=PASSWORD("NEW_PASSWORD") WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> exit
Infine, riavviate il demone mysqld:
# /etc/rc.d/mysqld restart
Fatto!
Troubleshooting
Mysql daemon cannot start
If you see something like this:
# /etc/rc.d/mysqld restart :: Stopping MySQL [FAIL] :: Starting MySQL [FAIL]
and no entry in log files, you might check permission of files in directories Template:Filename and Template:Filename. If owner of files in this directories is not mysql:mysql, you should do following:
# chown mysql:mysql /var/lib/mysql -R
If you run into permission problems despite having followed the above ensure that your Template:Filename is copied to /etc/:
# cp /etc/mysql/my.cnf /etc/my.cnf
Now try and restart the daemon.
If you get these messages in your Template:Filename
[ERROR] Can't start server : Bind on unix socket: Permission denied [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ? [ERROR] Aborting
you should change permissions of Template:Filename like so:
# chown mysql:mysql /var/run/mysqld -R
If you run mysqld and the following error appears:
Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist
Run the following command to install the default tables:
# mysql_install_db --user=mysql --ldata=/var/lib/mysql/
Unable to run mysql_upgrade because MySQL cannot start.
Try run MySQL in safemode:
# mysqld_safe --datadir=/var/lib/mysql/
And then run:
# mysql_upgrade -u root -p
How to Reset the Root Password
Stop mysqld daemon
# /etc/rc.d/mysqld stop # mysqld_safe --skip-grant-tables &
Connect to mysql server
# mysql -u root mysql
Change root password:
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> exit
Then restart daemon:
# /etc/rc.d/mysqld restart
You are done.