Posted by superuser
Thu, 11 Mar 2010 12:26:00 GMT
This is a guide on how to install and configure MySQL for the Joomla environment. For the demonstrations of this article i use a FreeBSD-8 OS. The paths for the executables files and the paths where mysql holds the databases it may be different in your case. For example FreeBSD uses most executables scripts on /usr/local/bin/ , while Linux on /usr/bin or /usr/sbin. The rest remains the same.
Installing mysql
Nearly all operating systems have their own package manager. The installation is a straightforward process. You should have root privileges to make a complete installation in binary or to build from sources.
For example:
# sudo apt-get install mysql-server [DEBIAN/UBUNTU]
# pacman -S mysql [ARCHLINUX]
# yum install mysql mysql-server [REDHAT/FEDORA]
# make WITH_CHARSET=utf8 install clean [FreeBSD]
You should note that in the case of FreeBSD, i compile using
WITH_CHARSET=utf8
because mysql by default sets a
latin1 character encoding. If you install mysql using the default latin1 encoding but you intend to use
utf8 characters in your app, you'll be in trouble. Check what default character encodings use your distribution for mysql server. As far as i know, Archlinux ships with default utf8 encodings, while Fedora with latin1, as FreeBSD does.
Configuration of mysql
Immediately after the completion of your installation you must create the directory where your databases will be stored . Again with root privileges:
# /usr/local/bin/mysql_install_db
Check that the directory /var/db/mysql has been created with a lot of stuff inside. In some distributions this directory (/var/db/mysql) has not the appropriate permissions for the group and it's owned by root. We should change that, otherwise mysql server will deny to start.
# chgrp -R mysql /var/db/mysql
# chown -R mysql /var/db/mysql
Starting mysql & Setting the mysql-Root password
Let's start now the mysql server
# /usr/local/bin/mysqld_safe -user=mysql &
[1] 2783
localhost# Starting mysqld daemon with databases from /var/db/mysql
If you don't get an error at this step, you can be sure that mysqld daemon is up and running..
When you need to stop the server (don't do this now)
$ mysqladmin -u root -p shutdown
From now on, we have no need for system-root privileges, so use your ordinary user account.
In our last step before starting to work with MySQL, is to set the password for the mysql-root account (mysql-root account is not related in anyway with the system-root account of your OS. Are completely different concepts. The first is a mysql user, the later a system user. The only conceptual thing in common is that both have full privileges for their environment). Replace new password with your secret mysql-root password.
$ /usr/local/bin/mysqladmin -u root password newpassword
Creating the database
It's time to create my mysql database now, i call it "joodb" :
$ mysqladmin -u root -p create joodb
Enter password: [enter your mysql root password here]
Check now that your database has been created. Enter at your mysql client and ask to SHOW DATABASES;:
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is xxx
Server version: 5.0.51a FreeBSD port: mysql-server-5.0.51a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>show databases;
Your database list should include joodb. Fine! joodb database is ready to use, but for security issues mysql permits the usage of a db only by privileged mysql-users. Except the root mysql-user, we do not have created any other. Now i'll set the privileges to use "joodb" for a mysql-user named "joom" with password "ladin". This user will be automatically created during the setting of the privilege. The sensible data are "joodb"(database name), "joom"(mysql-username), "ladin"(mysql-password) and the domain "localhost".
mysql> grant all privileges on joodb.* to 'joom'@'localhost'
identified by 'ladin';
Query OK, 0 rows affected (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
mysql> \q
Bye
flush privileges enables the privilege and pressing \q you exit the client.
Our database now is ready to use by a mysql-user named joom. Connecting my Joomla application with this database it means simply that i have to provide these informations to the configuration file of Joomla. In the section Database Settingsof the configuration.php i simply set:
#--- configuration.php ---
/* Database Settings */
var $dbtype = 'mysql';
var $host = 'localhost';
var $user = 'joom';
var $password = 'ladin';
var $db = 'joodb';
var $dbprefix = 'jos_';
That's all! We have succesfully created and configured our mysql database, created our mysql-user, set up the privileges and connected at our joomla application. Fire up now with your extra-galactica application.
Posted in Unix | Tags joomla, MySQL, setup | no comments
Posted by superuser
Fri, 27 Mar 2009 09:43:00 GMT
I had to transfer my old mysql databases from my old server to a new one. The source and destination servers runs different OSes but this is not a problem, the only requirement to succesfully transfer my dbs is to having setup the mysql server to the destination server. The following steps worked fine in my case. I do a complete backup of my Mysql databases, i transfer the backup file using scp (secure copy) and repristinate with a single command. All that you need is no more than three simple unix command lines.
First i create a complete backup of my mysql databases. There is no need to stop the mysql server to create this backup file. MysqlDump
blocks all databases during backup process. The following command will create the backup file backup.sql (provide your mysql root password when asked).
$ mysqldump -u root -p --all-databases > backup.sql
The second step consists in transfer the backup.sql file in my new server. Although you can use ftp or curl to do so, i prefer SecureCoPy. scp is a very cute unix command line which provides an easy and secure way to copy a single file or an entire directory from a host/server to another host/server node. From my old server i give
$ scp -pr fileORdirectory remote-user@remote-hostname-or-ip:directory/
, where "fileORdirectory" is my fileORdir from the old server,
"remote-user" is my system username to the remote server and "directory/" is the directory where the "fileORdirectory" will be moved on. The initial location is the home directory of the "remote-user", in the same way as you do with a simple ssh connection. Note that ":" is not a port symbol. Saying that now i'm sending my
backup.sql
$ scp -pr backup.sql remote-user@my.newserver.lan:mysql_backups/
Last step: Enter to your new server ("remote-user" should be your username) and make "mysqldump" targeting your backup.sql file to complete the migration.
$ mysql -u root -p < backup.sql
Note that in this way also the mysql root password will be copied to the new server. So, if during the installation you had setup a different root mysql password in the new server, after the backup process this will be changed to the root mysql password of the old server.
Posted in Unix | Tags migration, MySQL, mysqldump, scp, securecopy | 1 comment
Posted by superuser
Thu, 10 Apr 2008 20:25:00 GMT
Αν επιχειρήσετε να ξεκινήσετε την MySQL-5 στο FreeBSD - ή κάποιο άλλο πακέτο (Joomla, Drupal, ...) που εξαρτάται από αυτήν - πιθανώς να συναντήσετε κάποια δυσκολία στην εκκίνηση της διεργασίας 'mysqld'.Μερικά συνήθη σφάλματα που πιθανώς να δείτε είναι:
localhost# Starting mysqld daemon with databases from /var/db/mysql
STOPPING server from pid file /var/db/mysql/localhost.pid
080410 21:14:27 mysqld ended
ή
080410 21:10:52 mysqld started
080410 21:10:52 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
080410 21:10:52 mysqld ended
ή
/usr/local/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
Καταρχήν, αν δεν έχετε εγκαταστήσει ακόμη τον σέρβερ MySQL-5 αρκεί να ακολουθήσετε την διαδικασία εγκατάστασης από τις "Πόρτες" του FreeBSD {
# cd /usr/ports/databases/mysql50-server
Πιθανώς να επιθυμείτε να εγκαταστήσετε την MySQL με υποστήριξη για χαρακτήρες UTF-8 (συνήθες για την ελληνική γλώσσα, αλλά και για εφαρμογές που δουλεύουν UTF) . Σε αυτή την περίπτωση χρησιμποιήστε την εντολή :
make WITH_CHARSET=utf8 install clean
στον κατάλογο /usr/ports/databases/mysql50-server (η προσθήκη "WITH_CHARSET=utf8" κάνει τη διαφορά). Αν αντιθέτως δεν θέλετε προεπιλεγμένα κωδικοποίηση utf-8, αγνοήστε αυτή την παράγραφο. Δώστε μόνο
# make install clean
}
Αμέσως μετά την εγκατάσταση πρέπει να δημιουργήσουμε τον κατάλογο όπου θα αποθηκεύονται οι βάσεις δεδομένων μας.
# /usr/local/bin/mysql_install_db
Ελέγξτε ότι έχει δημιουργηθεί ο κατάλογος
/var/db/mysql. Σε αυτό ακριβώς το σημείο οφείλονται και τα προαναφερθέντα μηνύματος σφάλματος. Ο κατάλογος
/var/db/mysql δεν έχει τα κατάλληλα δικαιώματα χρήσης για τους χρήστες της ομάδας mysql και ο ιδιοκτήτης του καταλόγου είναι ο root. Με τις ακόλουθες δύο εντολές γραμμής θα αλλάξω τον ιδιοκτήτη και την ομάδα προς αποφυγήν των σφαλμάτων.
# chown -R mysql /var/db/mysql/
# chgrp -R mysql /var/db/mysql/
Ας ξεκινήσουμε τώρα την διεργασία mysqld
/usr/local/bin/mysqld_safe -user=mysql &
[1] 2783
localhost# Starting mysqld daemon with databases from /var/db/mysql
Μμμ, όλα εντάξει. Από δω και πέρα δεν χρειάζεται να ενεργούμε σαν root, επομένως κάνουμε logon σαν απλός χρήστης.
Το τελευταίο βήμα μας, πριν ξεκινήσουμε να δουλεύουμε με την MySQL, είναι να εισάγουμε τον κωδικό πρόσβασης του root της MySQL(ουδεμία σχέση έχει με τον root του συστήματος).
$ /usr/local/bin/mysqladmin -u root password newpassword
(όπου newpassword βάλτε τον δικό σας κωδικό πρόσβασης του root για την MySQL).
Είμαστε έτοιμοι για να τρέξουμε mysql:
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.51a FreeBSD port: mysql-server-5.0.51a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
Η διαδικασία εγκατάστασης καθώς και της επίλυσης των σφαλμάτων κατά την έναρξη της διεργασίας mysqld αναφέρεται εκτενώς σε διάφορα blog/τεκμηριώσεις/... Η αναφορά στο παρόν blog γίνεται για προσωπική διευκόλυνση,και για κάποιους πιθανώς που απλά προσπαθούν να εγκαταστήστουν κάποιον web application server που χρειάζεται MySQL.
Posted in FreeBSD | Tags 8, db, MySQL, MySQL, mysql_install_db, mysqladmin, mysqld, mysqld_safe, utf, var | 1 comment
Posted by superuser
Thu, 10 Apr 2008 20:25:00 GMT
Αν επιχειρήσετε να ξεκινήσετε την MySQL-5 στο FreeBSD - ή κάποιο άλλο πακέτο (Joomla, Drupal, ...) που εξαρτάται από αυτήν - πιθανώς να συναντήσετε κάποια δυσκολία στην εκκίνηση της διεργασίας 'mysqld'.Μερικά συνήθη σφάλματα που πιθανώς να δείτε είναι:
localhost# Starting mysqld daemon with databases from /var/db/mysql
STOPPING server from pid file /var/db/mysql/localhost.pid
080410 21:14:27 mysqld ended
ή
080410 21:10:52 mysqld started
080410 21:10:52 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
080410 21:10:52 mysqld ended
ή
/usr/local/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
Καταρχήν, αν δεν έχετε εγκαταστήσει ακόμη τον σέρβερ MySQL-5 αρκεί να ακολουθήσετε την διαδικασία εγκατάστασης από τις "Πόρτες" του FreeBSD {
# cd /usr/ports/databases/mysql50-server
Πιθανώς να επιθυμείτε να εγκαταστήσετε την MySQL με υποστήριξη για χαρακτήρες UTF-8 (συνήθες για την ελληνική γλώσσα, αλλά και για εφαρμογές που δουλεύουν UTF) . Σε αυτή την περίπτωση χρησιμποιήστε την εντολή :
make WITH_CHARSET=utf8 install clean
στον κατάλογο /usr/ports/databases/mysql50-server (η προσθήκη "WITH_CHARSET=utf8" κάνει τη διαφορά). Αν αντιθέτως δεν θέλετε προεπιλεγμένα κωδικοποίηση utf-8, αγνοήστε αυτή την παράγραφο. Δώστε μόνο
# make install clean
}
Αμέσως μετά την εγκατάσταση πρέπει να δημιουργήσουμε τον κατάλογο όπου θα αποθηκεύονται οι βάσεις δεδομένων μας.
# /usr/local/bin/mysql_install_db
Ελέγξτε ότι έχει δημιουργηθεί ο κατάλογος
/var/db/mysql. Σε αυτό ακριβώς το σημείο οφείλονται και τα προαναφερθέντα μηνύματος σφάλματος. Ο κατάλογος
/var/db/mysql δεν έχει τα κατάλληλα δικαιώματα χρήσης για τους χρήστες της ομάδας mysql και ο ιδιοκτήτης του καταλόγου είναι ο root. Με τις ακόλουθες δύο εντολές γραμμής θα αλλάξω τον ιδιοκτήτη και την ομάδα προς αποφυγήν των σφαλμάτων.
# chown -R mysql /var/db/mysql/
# chgrp -R mysql /var/db/mysql/
Ας ξεκινήσουμε τώρα την διεργασία mysqld
/usr/local/bin/mysqld_safe -user=mysql &
[1] 2783
localhost# Starting mysqld daemon with databases from /var/db/mysql
Μμμ, όλα εντάξει. Από δω και πέρα δεν χρειάζεται να ενεργούμε σαν root, επομένως κάνουμε logon σαν απλός χρήστης.
Το τελευταίο βήμα μας, πριν ξεκινήσουμε να δουλεύουμε με την MySQL, είναι να εισάγουμε τον κωδικό πρόσβασης του root της MySQL(ουδεμία σχέση έχει με τον root του συστήματος).
$ /usr/local/bin/mysqladmin -u root password newpassword
(όπου newpassword βάλτε τον δικό σας κωδικό πρόσβασης του root για την MySQL).
Είμαστε έτοιμοι για να τρέξουμε mysql:
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.51a FreeBSD port: mysql-server-5.0.51a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
Η διαδικασία εγκατάστασης καθώς και της επίλυσης των σφαλμάτων κατά την έναρξη της διεργασίας mysqld αναφέρεται εκτενώς σε διάφορα blog/τεκμηριώσεις/... Η αναφορά στο παρόν blog γίνεται για προσωπική διευκόλυνση,και για κάποιους πιθανώς που απλά προσπαθούν να εγκαταστήστουν κάποιον web application server που χρειάζεται MySQL.
Posted in FreeBSD | Tags 8, db, MySQL, MySQL, mysql_install_db, mysqladmin, mysqld, mysqld_safe, utf, var | 1 comment