Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] After copy Mysql DB to new server, no root access
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
bastibasti
Guru
Guru


Joined: 27 Nov 2006
Posts: 568

PostPosted: Fri Mar 04, 2011 9:59 am    Post subject: [SOLVED] After copy Mysql DB to new server, no root access Reply with quote

Hi Iam running a bugzilla. I got a new machine, and copied the /var/lib/mysql folder to the new machine.
Now I tried to add another user.
Code:

server ~ # mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


any advice?


Last edited by bastibasti on Sun Mar 06, 2011 9:03 am; edited 1 time in total
Back to top
View user's profile Send private message
cach0rr0
Bodhisattva
Bodhisattva


Joined: 13 Nov 2008
Posts: 4123
Location: Houston, Republic of Texas

PostPosted: Fri Mar 04, 2011 10:07 am    Post subject: Reply with quote

'tis not the best way to copy over databases, especially after a handful of storage engine changes that happened in the past recent history

if you must do things this way, start mysql in safe mode, change the password, see how you get on

if you're happy to redo things

-unmerge mysql
-re emerge mysql
-run mysql_install_db
-run mysql_secure_installation
-backup your databases from the old server via mysqldump
-import them onto the new server by hand via regular old mysql command-line
_________________
Lost configuring your system?
dump lspci -n here | see Pappy's guide | Link Stash
Back to top
View user's profile Send private message
bastibasti
Guru
Guru


Joined: 27 Nov 2006
Posts: 568

PostPosted: Fri Mar 04, 2011 12:53 pm    Post subject: Reply with quote

Thanks. Is there a howto for doing this? Mysql is not one of my best knowledged items
Back to top
View user's profile Send private message
cach0rr0
Bodhisattva
Bodhisattva


Joined: 13 Nov 2008
Posts: 4123
Location: Houston, Republic of Texas

PostPosted: Fri Mar 04, 2011 9:48 pm    Post subject: Reply with quote

bastibasti wrote:
Thanks. Is there a howto for doing this? Mysql is not one of my best knowledged items


hrmm...i dont know of a howto doc offhand, but i can give the basic commands

say you have a backup on your old server called, i dont know, 'gentoo'

to move it from old server to new:

on the old server:
Code:

mysqldump gentoo > gentoo.sql -p
(enter your root pass when prompted)


copy gentoo.sql over to the new server, then

On the new server:
Code:

mysqladmin create gentoo -p
(enter password when prompted)
mysql gentoo < gentoo.sql -p
(enter password when prompted)


if you used a different login to connect to this database other than root on the old server, you will need to set that back up

Code:

mysql -p
(enter root mysql pass when prompted)
mysql> grant all privileges on gentoo.* to 'gentoo'@'localhost' identified by 'whateveryouwantthepasswordtobe';
mysql> flush privileges;


That assumes you will be connecting to the database via localhost of course.

And now all of this assumes that you have already emerged mysql, run 'mysql_install_db', then started mysql and run 'mysql_secure_installation'
Those two commands will have on-screen instructions, that should be fairly self-explanatory.

You used to get a message from emerge after mysql was installed, saying "please run emerge --config=dev-db/mysql-5.1.x.whatever_version", which would do all of this for you. For some reason it seems this does not get shown any more.

Anyway, before you do anything else, unmerge mysql, and make sure /var/lib/mysql is empty. Then emerge mysql, run those two commands, and start moving your databases over via mysqldump and then the mysql dbname < backupfile.sql stuff.
_________________
Lost configuring your system?
dump lspci -n here | see Pappy's guide | Link Stash
Back to top
View user's profile Send private message
bastibasti
Guru
Guru


Joined: 27 Nov 2006
Posts: 568

PostPosted: Sun Mar 06, 2011 9:03 am    Post subject: Reply with quote

Thanks, I'll give it a try!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum