Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Sorry for the long post - I'm not exactly sure what my real problem is. I'm new to linux, and fairly new to the administration game. I'm used to using out of the box systems like WAMP on Windows - so forgive the stupidity you're about to hear.
I installed LAMP using tasksel (using this tutorial: http://www.unixmen.com/install-lamp-...erick-meerkat/) a while ago. I recently decided I wanted to learn how to build a CMS, and a tutorial I found suggested using Xampp to do so.
I installed Xampp. When starting XAMPP, I got the message "XAMPP: Another MySQL daemon is already running.", and MySQL was deactivated in the XAMPP status. After trying the usual methods to fix it, I followed a suggestion given to me on a forum and uninstalled a bunch of packages relating to LAMP. I still could not get Xampp to work, and after further searching was told it would not really suit my needs.
I uninstalled Xampp using "sudo rm -rf /opt/lamp", and tried to install Lamp using Tasksel again. However, I now I get the error "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)" during installation.
Clearly I've done some damage. I'm happy to use Lamp if that's the wisest option, though I was attracted by Xampp cosmetic user-friendliness. Thoughts on what I should do next?
Last edited by southpointingchariot; 09-03-2012 at 03:58 PM.
Looking at your browser-icon you appear to be running Ubuntu. Do a search for
"ubuntu reset mysql password". Or, if you don't have any important data in your
installation of MySQL at this stage, just purge the install, and re-install it.
Looking at your browser-icon you appear to be running Ubuntu. Do a search for
"ubuntu reset mysql password". Or, if you don't have any important data in your
installation of MySQL at this stage, just purge the install, and re-install it.
Cheers,
Tink
Thanks for your help! As I used tasksel, I'm not exactly sure what package actually contains MySQL. Is it "mysql-server"?
Also, you purge a package with "sudo apt-get purge <package>", correct?
There are a couple of ways to go about it. Remove the mysql database and let the service re-create one without a password.
Code:
service mysqld stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
service mysqld start
The better alternative is to simply reset the root password within MySQL (see first link on page).
The problem here is not with mysql me thinks though. As root run mysql, you should be able to get right in without changing anything. LAMPP is apparently attempting to access mysql with a password which fails even when there is no password.
Since you're on Ubuntu I would suggest rather than installing XaMPP or LAMPP to simply install the packages separate using what is available.
Code:
sudo apt-get install apache2 mysql mysql-server
You can modify the http files in /var/www/ and access mysql through port 3306 using a local mysql client (the "mysql" command). One word of warning, you should enable a firewall so that external machines on your local network can connect to MySQL. There's a well known security flaw that the root pword can easily be brute forced with a simple login loop (takes only a few seconds).
There are a couple of ways to go about it. Remove the mysql database and let the service re-create one without a password.
Code:
service mysqld stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
service mysqld start
The better alternative is to simply reset the root password within MySQL (see first link on page).
The problem here is not with mysql me thinks though. As root run mysql, you should be able to get right in without changing anything. LAMPP is apparently attempting to access mysql with a password which fails even when there is no password.
Since you're on Ubuntu I would suggest rather than installing XaMPP or LAMPP to simply install the packages separate using what is available.
Code:
sudo apt-get install apache2 mysql mysql-server
You can modify the http files in /var/www/
Thanks for your help! I should probably clarify that I have never intentionally done anything with MySQL, and a complete newb newb about it at this point (this was in fact what I was attempting to do something about that sparked this whole saga).
Your first solution returned "mysqld: unrecognized service".
After examining the "Unix Systems" section of the link you suggested (http://dev.mysql.com/doc/refman/5.0/...rmissions.html), I am left with more questions. How do I figure out what user mysqld runs as? It's a personal computer, so its either me or root.
When attempting to install the programs as you suggested, I get "E: Unable to locate package mysql"
Apologies, I should double check the commands. Here, let's go through the process and you can follow along. Let's go into a root prompt but be very careful in there!
Code:
sudo su -
apt-cache search mysql | grep ^mysql
apt-get install mysql-server mysql-client
ls /etc/init.d | grep mysql
#note at this point you should see mysql
#you can invoke the service in one of two ways, by using /etc/init.d/mysql or with the following.
service mysql status
#start the mysql service if it is stopped
service mysql start
#now let's open mysql using the mysql client (it is a command)
mysql
#to quit mysql run the following
quit;
#we're now back at the shell
exit
#we're no longer logged in as root
You can do the same for apache or httpd (forget which it is called on Ubuntu). Are you running Ubuntu 12.04? If you're not sure you can do the following.
Apologies, I should double check the commands. Here, let's go through the process and you can follow along. Let's go into a root prompt but be very careful in there!
Code:
sudo su -
apt-cache search mysql | grep ^mysql
apt-get install mysql-server mysql-client
ls /etc/init.d | grep mysql
#note at this point you should see mysql
#you can invoke the service in one of two ways, by using /etc/init.d/mysql or with the following.
service mysql status
#start the mysql service if it is stopped
service mysql start
#now let's open mysql using the mysql client (it is a command)
mysql
#to quit mysql run the following
quit;
#we're now back at the shell
exit
#we're no longer logged in as root
You can do the same for apache or httpd (forget which it is called on Ubuntu). Are you running Ubuntu 12.04? If you're not sure you can do the following.
Code:
cat /etc/issue
I am on 12.04. When following your instructions, I get "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)" when attempting to open the client.
When I said I did some damage, I wasn't joking . This is easily my most embarrassing technical story. I broke every bloody rule. Thank you again for your help!
Is it okay if we blow away the old database? Or would you rather keep it around and simply reset the password? Also if you just so happen to remember the password you can log into mysql using a password.
sudo su -
service mysql stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
#now there should be no databases
service mysql start
#now there should be a default database again, use ls to see
Remember, you shouldn't take any forum member's advice without understanding the commands you're running. If there's a command you don't understand, ask, if there are command options which you're not familiar then look at the man page for that command.
e.g. man rm, look at the options -r and -f to see what they do.
Once you have a new database you should be able to open the database using the "mysql" client command.
sudo su -
service mysql stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
#now there should be no databases
service mysql start
#now there should be a default database again, use ls to see
Remember, you shouldn't take any forum member's advice without understanding the commands you're running. If there's a command you don't understand, ask, if there are command options which you're not familiar then look at the man page for that command.
e.g. man rm, look at the options -r and -f to see what they do.
Once you have a new database you should be able to open the database using the "mysql" client command.
SAM
I'm familiar with -rf and such, but your advice is very good .
On that line of thought, I'm not sure if there are any databases (what extension would they be?). ls returns:
debian-5.5.flag ib_logfile1 performance_schema
ibdata1 mysql test
ib_logfile0 mysql_upgrade_info
If there's anything then you're good. Just run the following command,
Code:
mysql -u root
You should see a mysql> prompt now. If you want to change the password for the root user (highly recommended) then run the following command,
Code:
#first time only
mysqladmin -u root password
#if you ever want to change the password then you'll need to connect by using the password option
#since you would have already had a password.
mysqladmin -u root -p password
When ever you're working in a CMS it's best to not allow it to use the root mysql user. Create a database, create a user, and then grant that user access to the database. Here's an example (all mysql code).
Code:
CREATE USER 'mycms'@'localhost' IDENTIFIED BY 'mycms';
CREATE DATABASE mycms;
GRANT ALL PRIVILEGES TO mycms.* TO 'mycms'@'localhost' IDENTIFIED BY 'mycms';
The capitalized sql is not case sensitive but I used it to emphasize the difference between commands and arguments.
We created a user mycms who is identified by the password mycms. Then we granted access to the database mycms to the user mycms. Now quit; mysql and then log in as your new mycms user. You should only be able to see the database it has privileges to.
Code:
#Note: mysql -u [user] -p[password] [database]
mysql -u mycms -pmycms mycms
#you're now logged into mysql so let's see the databases.
show databases;
By having a user only allowed to access it's own database you can install multiple databases and users who won't be able to touch each others data. This comes in handy when you're running more than one CMS or if you're running more than *just* a CMS.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.