I've made a simple CLI tool to manage mysql privileges. It's written in PHP, and uses a PHP lib to talk to mysql. The first thing the tool needs, is mysql credentials, because the PHP lib needs those to talk to the mysql daemon (probably on the same server). That works, BUT
I need it to work without credentials. On some servers, I can only run mysql with sudo mysql and then be logged in as mysql root. That's fine too, but my tool can't use that.
Can I wrap my tool around the mysql client, instead of initiating a mysql client inside the tool?
If I can do that, the tool works with any auth method:
sudo mysql | tool
mysql --login-path=~/.mysql-creds | tool
mysql -ufoo -pbar | tool
mysql -hdb.server.com -upublic | tool
But how? How do I get the tool talking to the process around/outside it?
I could use PHP's proc functions to init the process in PHP and read/write from there, but I'm interested in any tool around any process, without knowing the process' name/location. (The tool shouldn't have to know mysql -ufoo -pbar or sudo mysql.)
These don't work:
mysql | tool
mysql < tool
tool < mysql
Or without PHP. How would Python do this? Or even Bash?
Related
I'm getting started with Data Grip and I'm stuck before I started doing anything. First thing I've done was creating postgre Data Source with default parameters.
Now I opened a console, and tried to run a script:
drop table table1;
The console then prints:
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
What can I do about that, so that I could create my project in e.g.: D:\Database\ instead of connecting to other hosts?
Sounds like you're not actually running PostgreSQL locally. Is it installed and running? PostgreSQL is a client/server-based database system, so it requires the server process to be running. This is not like SQLite or HSQLDB that run self-contained within your application (or DataGrip in this case). Please see here for a tutorial on how to get started with Postgres on a Mac. There are similar tutorials for other operating systems.
I want to ask if I can use NAS to store the main database like for example Firebird or MySQL and access this database from network ? if so how to install the database server software ?
Sure!
What's your nas model?
For example in my Synology i can enable web server and install mysql + phpmyadmin just in few clicks.
I just need to access in the admin panel and using the PacketManager start installing the software.
I'm sure it's possible to do the same with Qnap.
A "NAS" is simply Network Attached Storage. A personal example is the Western Digital My Cloud. You can use it to host the data files themselves, but no software can be installed.
There are networked solutions that are basically mini servers. They have slimmed down versions of a Linux build that run web servers, database servers and the like. I do not have any examples to provide since I do not have the need for one, but I know they are out there from prior research.
To learn about what a NAS is, you can check out the Wikipedia article.
NAS is basically just storage, it doesn't really run a useful OS. You need a server to host MySQL or similar DB. You can install MySQL on a Windows, Mac or Linux OS, the DB file(s) would reside on those machines and the MySQL services would respond to API requests appropriately. Here are some links to installing MySQL:
Windows - http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/install-and-configure-mysql-for-php-applications-on-iis-7-and-above
Linux - https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu
I know Heroku has a command line client to execute a .sql file.
But is there something like an SQL Server Management Studio for databases deployed at Heroku? I was looking for a UI that allows you to interactively write queries, execute them, and view the results on a grid. I'll mostly execute SELECTs and UPDATEs based on ids, over databases generated by Rails.
Have a look at Adminium: it's a free control panel plugin for Heroku.
https://addons.heroku.com/adminium
Take a look at http://www.pgadmin.org/ and install pgAdmin III. I use it for the same purpose, watch and query over the database of one of my Heroku apps.
I have a multiple scripts I need to execute on test servers (we have 20 test servers)
Is there any method for doing this quickly or any tool that can manage this vs doing the whole process manually?
Beside using SQLCMD which is a manual and time consuming process, or Server groups in SSMS you can also use a third party tool, ApexSQL Build.
Here is the article with a detailed explanation on how to accomplish this using this tool: SQL Database deployment on several different SQL Server instances and databases
Disclaimer: I work for ApexSQL as a Support Engineer
I'm currently working a contract for a company which will be moving an access database to MS SQL server in the future, and I'd like to hone my skills before the company makes the switch.
I'm also looking forward to possibly developing a rudimentary website which would have a simple HTML/CSS/JS front end, and those skills could also use a sharpening. I'd like to develop my skills through some SQL work locally on my home computer. Researching how to do that has only yielded the suggestion of installing an Apache web server with PHP and MySQL on my local machine. While I'm not opposed to doing that, the last time I worked with an Apache install, it was over-complicated and bloated.
Is there a more streamlined option? It doesn't seem necessary to load an entire web server for the specific use I'm going for.
I'd prefer to simply install a program that allows me to host the [My]SQL database locally, and perhaps later some way to test HTML and Javascript interacting with the database. I'm already somewhat familiar with Sequel Pro. As an added bonus, my Python skills are rusty and I'd like to get used to scripting Python. At this point Xcode (4.2) seems the likely solution here, but I'm open to other options.
I would be installing on a 11" MacBook Air running Lion and Xcode 4.2.
Apache and PHP ship with Mac OS X 10.7. MySQL installation is pretty straightforward with the package available from MySQL.
Take a look at these instructions--for your purposes, you can stop after the php.ini section.
Obviously a very subjective question.
I find CherryPy (with Python) for the web server and server programming, combined with jQuery to augment the HTML in the browser to be a powerful and lightweight combination. When possible, I use SQLite for the database — another extremely lightweight option. I share your distaste for Apache, at least when it's not needed.
If you want to develop solid skills that are peculiar to MS SQL Server, you really don't have much alternative to installing SQL Server someplace you can access it. Although you can certainly limit your use of SQL Server to standard SQL set-based commands SQL Server is more often used with a heavy emphasis on procedural code built into stored procedures. Those skills (writing SQL Server specific stored procedures) are only very minimally transferable to or from other database products.
If you were running Windows, you could get MS SQL Server Express for free:
http://www.microsoft.com/sqlserver/en/us/editions/express.aspx
In the end I just installed MySQL. I ended up following the instructions available from this blog post about setting up django, but not installing phpMyAdmin...
This post also has some good things about setting up passwords and such, since I really didn't want to be stuck relying on something else to admin the MySQL setup.