Recently, I had to rebuild a tikiwiki server (on a Linux machine) with only a mysql database backup image. I quickly found that the backup image of a tikiwiki does not contain the version of the tikiwiki software, which is very necessary; otherwise, the database schema won’t match. Fortunately, I managed to find that the tikiwiki version was 1.8.5 from some old notes.
Here is the resulting software stack after I finished.
- Red Hat Enterprise Linux AS Release 4
- mySQL Server 4.1.20
- Apache HTTP Server 2.0.52
- PHP 4.3.9
- Tikiwiki 1.8.5 Polaris
Here’s how I went about restoring the tikiwiki (assuming that the machine already has Redhat AS4 installed):
- Install PHP, HTTP Daemon (httpd), and supporting libraries:yum list | grep -i php
yum install php.i386 - Install mySQL server (mysqld) and supporting libraries:yum list | grep -i mysql
yum install mysql-server.i386 - Install mySQL client and the PHP-mySQL libraries:yum list | grep -i php-mysql
yum install php-mysql.i386 - Start both mysqld and httpd and configure them to start on reboot:chkconfig mysqld on
service mysqld start
chkconfig httpd on
service httpd start - Configure mysqld and setup database:(Set mySQL root password)
mysqladmin -u root password 'mypassword'
(Create a database)
mysqladmin -u root -p create mydatabase
(Login as mySQL root user)
mysql -u root -p
(Use main mySQL database)
mysql> use mysql;
(Give localhost permission to access all databases)
mysql> insert into host(host, db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv) values('localhost', '%', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
(Create a user)
mysql> insert into user (host, user, password) values('localhost', 'myuser', password('mypassword'));
(Give that user access to the created database from localhost)
mysql> insert into db (host, db, user, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv) values ('localhost', 'mydatabase', 'myuser', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
(Quit from mySQL)
mysql> quit;
(Reload mySQL server)
mysqladmin -u root -p reload - Reload the HTTP Server just in case:service httpd reload
- Make sure that PHP is working by copying this testphp.php file to “/var/www/html” and browsing to “http://localhost/testphp.php”:<html>
<head>
<title>PHP Info Script</title>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html> - Make sure that PHP-mySQL is working by copying this testmysql.php file to “/var/www/html”, replacing the text ”mysql_root_password” with your real password, and browsing to “http://localhost/testmysql.php”:<html>
<title>mySQL Test Script</title>
<body>
<?php
// connect and select a database
$link = mysql_connect("localhost:3306", "root", "mysql_root_password")
or die ("Couldn't connect: Check to make sure that:<br>" .
"<ul><li>your MySQL server is running</li>" .
"<li>you used the correct hostname (<tt>vergil/ovid</tt>)</li>" .
"<li>you added a colon with your port number after the hostname</li>" .
"<li>you used the username 'root'</li>" .
"<li>you used the correct root password</li>" .
"<li>you didn't forget to close a set of quotation marks</li><br><br>");
print "Connected successfully.<br>";
$db = "mysql";
mysql_select_db($db) or die("Could not select the database '" . $db . "'. Are you sure it exists?");
// perform an SQL query
$query = "SELECT * FROM user";
$result = mysql_query($query) or die("Query failed");
// print the result of the first row (row counting starts at zero)
printf("Host: %s<br>\n", mysql_result($result, 0, "Host"));
printf("User: %s<br>\n", mysql_result($result, 0, "User"));
printf("Grant privilege: %s<br>\n", mysql_result($result, 0, "Grant_priv"));
// free result set
mysql_free_result($result);
// close the connection
mysql_close($link);
?>
</body>
</html> - Unzip the tikiwiki 1.8.5 archive to the “/var/www/html” directory and run the setup script:chmod u+x setup.sh
./setup.sh
chmod u-x setup.sh - Configure the tikiwiki by browsing to ”http://localhost/tiki-install.php” and inputting the tikiwiki database name, user, and password.
- Restore the database from the backup image:mysql -u root -p
mysql> use tikiwiki;
mysql> source tiki_backup.sql - And we are done!
Some info above was provided by Linux Help – mySQL setup Guide.
No comments:
Post a Comment